0.9.0-1: Add Docker file and automated builds using forgejo actions

This commit is contained in:
Fijxu 2024-09-10 23:22:27 -03:00
parent cbeba2b0a2
commit e1a64b225d
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
4 changed files with 85 additions and 2 deletions

48
.forgejo/workflows/ci.yml Normal file
View file

@ -0,0 +1,48 @@
name: 'File-uploader-crystal CI'
on:
# workflow_dispatch:
# inputs: {}
schedule:
- cron: '0 7 * * 0'
push:
branches:
- "master"
jobs:
build:
runs-on: runner
steps:
- uses: https://code.forgejo.org/actions/checkout@v2
- uses: https://code.forgejo.org/docker/setup-buildx-action@v3
name: Setup Docker BuildX system
- name: Login to Docker Container Registry
uses: https://code.forgejo.org/docker/login-action@v3.1.0
with:
registry: git.nadeko.net
username: ${{ secrets.USERNAME }}
password: ${{ secrets.TOKEN }}
- name: Docker meta
id: meta
uses: https://github.com/docker/metadata-action@v5
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}', 'master') }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
- uses: https://code.forgejo.org/docker/build-push-action@v5
name: Build images
with:
context: .
file: docker/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64
push: true
build-args: |
"release=1"

35
Dockerfile Normal file
View file

@ -0,0 +1,35 @@
# Based on https://github.com/iv-org/invidious/blob/master/docker/Dockerfile
FROM crystallang/crystal:1.13.2-alpine AS builder
RUN apk add --no-cache sqlite-static yaml-static
ARG release
WORKDIR /file-uploader-crystal
COPY ./shard.yml ./shard.yml
COPY ./shard.lock ./shard.lock
RUN shards install --production
COPY ./src/ ./src/
# TODO: .git folder is required for building this is destructive.
# See definition of CURRENT_BRANCH, CURRENT_COMMIT and CURRENT_VERSION.
COPY ./.git/ ./.git/
RUN crystal build ./src/file-uploader-crystal.cr \
--release \
--static --warnings all
RUN apk add --no-cache tini
FROM alpine:3.18
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/
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
EXPOSE 8080
USER invidious
ENTRYPOINT ["/sbin/tini", "--"]
CMD [ "/invidious/file-uploader" ]

View file

@ -1,4 +1,4 @@
name: file-uploader
name: file-uploader-crystal
version: 0.8.7
authors:
@ -6,7 +6,7 @@ authors:
targets:
file-uploader:
main: src/file-uploader.cr
main: src/file-uploader-crystal.cr
dependencies:
kemal: