Skip to content

Commit 6b6d5f3

Browse files
authored
ci: create alpine images to allow running commands inside the container (#992)
* feat: build alpine tag alongisde slim tag * fix: warnings in Dockerfile * docs: updated bash reference
1 parent 4a58ef0 commit 6b6d5f3

File tree

7 files changed

+70
-9
lines changed

7 files changed

+70
-9
lines changed

.github/workflows/_buildx.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
name: "Build Docker"
22

3-
on: workflow_call
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag_prefix:
7+
description: 'The tag prefix to use'
8+
required: false
9+
type: string
10+
default: ''
11+
dockerfile:
12+
description: 'The Dockerfile to use'
13+
required: false
14+
type: string
15+
default: 'Dockerfile'
16+
417
jobs:
518
buildx:
619
runs-on: ubuntu-latest
@@ -22,7 +35,7 @@ jobs:
2235
run: |
2336
REPO=ghcr.io/${{ github.repository }}
2437
TAG=$(git describe --tags)
25-
echo "tag_flags=--tag $REPO:$TAG" >> $GITHUB_ENV
38+
echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}$TAG" >> $GITHUB_ENV
2639
2740
# New tagged version
2841
- name: Prepare version push tags
@@ -36,18 +49,18 @@ jobs:
3649
else
3750
TAG2="latest"
3851
fi
39-
echo "tag_flags=--tag $REPO:$TAG --tag $REPO:$TAG2" >> $GITHUB_ENV
52+
echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}$TAG --tag $REPO:${{ inputs.tag_prefix }}$TAG2" >> $GITHUB_ENV
4053
4154
# Every pull request
4255
- name: Prepare pull request tags
4356
if: github.event_name == 'pull_request'
4457
run: |
4558
echo "tag_flags=--tag ${{ github.ref }}" >> $GITHUB_ENV
4659
REPO=ghcr.io/${{ github.repository }}
47-
echo "tag_flags=--tag $REPO:pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
60+
echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
4861
4962
- name: Buildx
5063
run: |
5164
set -x
5265
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u "${{ github.repository_owner }}" --password-stdin ghcr.io
53-
make buildx CONTAINER_BUILDX_OPTIONS="--push ${{ env.tag_flags }}"
66+
make buildx CONTAINERFILE_NAME=${{ inputs.dockerfile }} CONTAINER_BUILDX_OPTIONS="--push ${{ env.tag_flags }}"

.github/workflows/pull_request.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ jobs:
3131
# only build on pull requests from the same repo for now
3232
if: github.event.pull_request.head.repo.full_name == github.repository
3333
uses: ./.github/workflows/_buildx.yml
34+
call-buildx-alpine:
35+
needs: call-gorelease
36+
# only build on pull requests from the same repo for now
37+
if: github.event.pull_request.head.repo.full_name == github.repository
38+
uses: ./.github/workflows/_buildx.yml
39+
with:
40+
tag_prefix: alpine-
41+
dockerfile: Dockerfile.alpine

.github/workflows/push.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,11 @@ jobs:
2424
call-buildx:
2525
needs: call-gorelease
2626
uses: ./.github/workflows/_buildx.yml
27+
call-buildx-alpine:
28+
needs: call-gorelease
29+
# only build on pull requests from the same repo for now
30+
if: github.event.pull_request.head.repo.full_name == github.repository
31+
uses: ./.github/workflows/_buildx.yml
32+
with:
33+
tag_prefix: alpine-
34+
dockerfile: Dockerfile.alpine

.github/workflows/version_bump.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ jobs:
3636
call-buildx:
3737
needs: call-gorelease
3838
uses: ./.github/workflows/_buildx.yml
39+
call-buildx-alpine:
40+
needs: call-gorelease
41+
# only build on pull requests from the same repo for now
42+
if: github.event.pull_request.head.repo.full_name == github.repository
43+
uses: ./.github/workflows/_buildx.yml
44+
with:
45+
tag_prefix: alpine-
46+
dockerfile: Dockerfile.alpine

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Build stage
2-
ARG ALPINE_VERSION
3-
ARG GOLANG_VERSION
2+
ARG ALPINE_VERSION=3.19
43

54
FROM docker.io/library/alpine:${ALPINE_VERSION} AS builder
65
ARG TARGETARCH
@@ -14,7 +13,7 @@ RUN apk add --no-cache ca-certificates tzdata && \
1413
# Server image
1514
FROM scratch
1615

17-
ENV PORT 8080
16+
ENV PORT=8080
1817
ENV SHIORI_DIR=/shiori
1918
WORKDIR ${SHIORI_DIR}
2019

Dockerfile.alpine

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ARG ALPINE_VERSION=3.19
2+
3+
FROM docker.io/library/alpine:${ALPINE_VERSION}
4+
ARG TARGETARCH
5+
ARG TARGETOS
6+
ARG TARGETVARIANT
7+
COPY dist/shiori_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}/shiori /usr/bin/shiori
8+
RUN apk add --no-cache ca-certificates tzdata && \
9+
chmod +x /usr/bin/shiori && \
10+
rm -rf /tmp/* && \
11+
apk cache clean
12+
13+
ENV PORT=8080
14+
ENV SHIORI_DIR=/shiori
15+
WORKDIR ${SHIORI_DIR}
16+
17+
LABEL org.opencontainers.image.source="https://github.com/go-shiori/shiori"
18+
LABEL maintainer="Felipe Martin <github@fmartingr.com>"
19+
20+
EXPOSE ${PORT}
21+
22+
ENTRYPOINT ["/usr/bin/shiori"]
23+
CMD ["server"]

docs/Usage.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ The above command will :
3434

3535
After you've run the container in background, you can access console of the container:
3636

37+
> In order to be able to access the container and execute commands you need to use the `alpine-` prefixed images.
38+
3739
```
38-
docker exec -it shiori sh
40+
docker exec -it shiori ash
3941
```
4042

4143
Now you can use `shiori` like normal. If you've finished, you can stop and remove the container by running :

0 commit comments

Comments
 (0)