diff --git a/.github/workflows/_buildx.yml b/.github/workflows/_buildx.yml index 721cf25b8..06277b33b 100644 --- a/.github/workflows/_buildx.yml +++ b/.github/workflows/_buildx.yml @@ -1,6 +1,19 @@ name: "Build Docker" -on: workflow_call +on: + workflow_call: + inputs: + tag_prefix: + description: 'The tag prefix to use' + required: false + type: string + default: '' + dockerfile: + description: 'The Dockerfile to use' + required: false + type: string + default: 'Dockerfile' + jobs: buildx: runs-on: ubuntu-latest @@ -22,7 +35,7 @@ jobs: run: | REPO=ghcr.io/${{ github.repository }} TAG=$(git describe --tags) - echo "tag_flags=--tag $REPO:$TAG" >> $GITHUB_ENV + echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}$TAG" >> $GITHUB_ENV # New tagged version - name: Prepare version push tags @@ -36,7 +49,7 @@ jobs: else TAG2="latest" fi - echo "tag_flags=--tag $REPO:$TAG --tag $REPO:$TAG2" >> $GITHUB_ENV + echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}$TAG --tag $REPO:${{ inputs.tag_prefix }}$TAG2" >> $GITHUB_ENV # Every pull request - name: Prepare pull request tags @@ -44,10 +57,10 @@ jobs: run: | echo "tag_flags=--tag ${{ github.ref }}" >> $GITHUB_ENV REPO=ghcr.io/${{ github.repository }} - echo "tag_flags=--tag $REPO:pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV + echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV - name: Buildx run: | set -x echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u "${{ github.repository_owner }}" --password-stdin ghcr.io - make buildx CONTAINER_BUILDX_OPTIONS="--push ${{ env.tag_flags }}" + make buildx CONTAINERFILE_NAME=${{ inputs.dockerfile }} CONTAINER_BUILDX_OPTIONS="--push ${{ env.tag_flags }}" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 07ac7c764..a71adf146 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -31,3 +31,11 @@ jobs: # only build on pull requests from the same repo for now if: github.event.pull_request.head.repo.full_name == github.repository uses: ./.github/workflows/_buildx.yml + call-buildx-alpine: + needs: call-gorelease + # only build on pull requests from the same repo for now + if: github.event.pull_request.head.repo.full_name == github.repository + uses: ./.github/workflows/_buildx.yml + with: + tag_prefix: alpine- + dockerfile: Dockerfile.alpine diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index be8267ffa..d28ddd3b2 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -24,3 +24,11 @@ jobs: call-buildx: needs: call-gorelease uses: ./.github/workflows/_buildx.yml + call-buildx-alpine: + needs: call-gorelease + # only build on pull requests from the same repo for now + if: github.event.pull_request.head.repo.full_name == github.repository + uses: ./.github/workflows/_buildx.yml + with: + tag_prefix: alpine- + dockerfile: Dockerfile.alpine diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 18c399b96..891886f34 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -36,3 +36,11 @@ jobs: call-buildx: needs: call-gorelease uses: ./.github/workflows/_buildx.yml + call-buildx-alpine: + needs: call-gorelease + # only build on pull requests from the same repo for now + if: github.event.pull_request.head.repo.full_name == github.repository + uses: ./.github/workflows/_buildx.yml + with: + tag_prefix: alpine- + dockerfile: Dockerfile.alpine diff --git a/Dockerfile b/Dockerfile index 22ca22279..9bfc9142c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ # Build stage -ARG ALPINE_VERSION -ARG GOLANG_VERSION +ARG ALPINE_VERSION=3.19 FROM docker.io/library/alpine:${ALPINE_VERSION} AS builder ARG TARGETARCH @@ -14,7 +13,7 @@ RUN apk add --no-cache ca-certificates tzdata && \ # Server image FROM scratch -ENV PORT 8080 +ENV PORT=8080 ENV SHIORI_DIR=/shiori WORKDIR ${SHIORI_DIR} diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 000000000..1bd909145 --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,23 @@ +ARG ALPINE_VERSION=3.19 + +FROM docker.io/library/alpine:${ALPINE_VERSION} +ARG TARGETARCH +ARG TARGETOS +ARG TARGETVARIANT +COPY dist/shiori_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}/shiori /usr/bin/shiori +RUN apk add --no-cache ca-certificates tzdata && \ + chmod +x /usr/bin/shiori && \ + rm -rf /tmp/* && \ + apk cache clean + +ENV PORT=8080 +ENV SHIORI_DIR=/shiori +WORKDIR ${SHIORI_DIR} + +LABEL org.opencontainers.image.source="https://github.com/go-shiori/shiori" +LABEL maintainer="Felipe Martin " + +EXPOSE ${PORT} + +ENTRYPOINT ["/usr/bin/shiori"] +CMD ["server"] diff --git a/docs/Usage.md b/docs/Usage.md index 74d7798f6..a746ee2f8 100644 --- a/docs/Usage.md +++ b/docs/Usage.md @@ -34,8 +34,10 @@ The above command will : After you've run the container in background, you can access console of the container: +> In order to be able to access the container and execute commands you need to use the `alpine-` prefixed images. + ``` -docker exec -it shiori sh +docker exec -it shiori ash ``` Now you can use `shiori` like normal. If you've finished, you can stop and remove the container by running :