diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 3d031b0..69bd367 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -1,8 +1,7 @@ name: 'File-uploader-crystal CI' on: - # workflow_dispatch: - # inputs: {} + workflow_dispatch: schedule: - cron: '0 7 * * 0' push: @@ -28,14 +27,14 @@ jobs: - name: Docker meta id: meta - uses: https://github.com/docker/metadata-action@v5 + uses: https://github.com/docker/metadata-action@v6 with: images: git.nadeko.net/fijxu/file-uploader-crystal tags: | type=sha,format=short,prefix={{date 'YYYY.MM.DD'}}-,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - - uses: https://code.forgejo.org/docker/build-push-action@v5 + - uses: https://code.forgejo.org/docker/build-push-action@v6 name: Build images with: context: . @@ -43,5 +42,5 @@ jobs: tags: ${{ steps.meta.outputs.tags }} platforms: linux/amd64 push: true - build-args: | - "release=1" + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 3e06b49..fe2ccc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ # Based on https://github.com/iv-org/invidious/blob/master/docker/Dockerfile -FROM crystallang/crystal:1.14.0-alpine AS builder +FROM crystallang/crystal:1.16.1-alpine AS builder RUN apk add --no-cache sqlite-static yaml-static -ARG release +WORKDIR /file-uploader-crystal -WORKDIR /file-uploader-crystal COPY ./shard.yml ./shard.yml COPY ./shard.lock ./shard.lock RUN shards install --production @@ -15,21 +14,29 @@ COPY ./src/ ./src/ # See definition of CURRENT_BRANCH, CURRENT_COMMIT and CURRENT_VERSION. COPY ./.git/ ./.git/ -RUN crystal build ./src/file-uploader-crystal.cr \ +RUN --mount=type=cache,target=/root/.cache/crystal \ + crystal build ./src/file-uploader-crystal.cr \ --release \ --static --warnings all -FROM alpine:3.20 +# 2nd stage +FROM alpine:3.21 RUN apk add --no-cache tini ffmpeg + WORKDIR /file-uploader-crystal + RUN addgroup -g 1000 -S file-uploader-crystal && \ adduser -u 1000 -S file-uploader-crystal -G file-uploader-crystal -COPY --chown=file-uploader-crystal ./config/config.* ./config/ + +COPY --chown=file-uploader-crystal ./config/config.example.yml ./config/ RUN mv -n config/config.example.yml config/config.yml -COPY --from=builder /file-uploader-crystal/file-uploader-crystal . -RUN chmod o+rX -R ./config +COPY --from=builder /file-uploader-crystal/file-uploader-crystal /file-uploader-crystal +RUN chmod o+rX -R /file-uploader-crystal/file-uploader-crystal +RUN chown file-uploader-crystal: -R /file-uploader-crystal EXPOSE 8080 USER file-uploader-crystal + ENTRYPOINT ["/sbin/tini", "--"] + CMD [ "/file-uploader-crystal/file-uploader-crystal" ]