From 613582756eee3942c8e08780620f2931629724c2 Mon Sep 17 00:00:00 2001 From: Salvoxia Date: Mon, 3 Feb 2025 20:02:56 +0100 Subject: [PATCH 1/2] Workflows: Build Docker image as part of CI pipeline (without pushing) --- .github/workflows/ci.yaml | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fbaa4b2..4df5c4a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,3 +27,48 @@ jobs: - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') + docker: + name: Build Docker Image + needs: lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Convert repository name ot image name + id: image_name + run: | + sed -E -e 's/docker-//' -e 's/^/image_name=/' <<<"${{ github.repository }}" >> "$GITHUB_OUTPUT" + + - name: Generate Docker tag names + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/${{ steps.image_name.outputs.image_name }} + ${{ steps.image_name.outputs.image_name }} + # generate Docker tags based on the following events/attributes + tags: | + # set edge tag for default branch + type=edge,enable={{is_default_branch}} + # set dev tag for dev branch + type=raw,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'dev') }},branch=dev + # Tags for non SemVer tag names + type=match,pattern=([0-9]+.*),group=1 + # latest tag for any tags + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }},event=tag + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 + push: false + tags: ${{ steps.meta.outputs.tags }} From 63036ad5328d6d5cf5feb879e36b3d355fbd6290 Mon Sep 17 00:00:00 2001 From: Salvoxia Date: Mon, 3 Feb 2025 20:37:00 +0100 Subject: [PATCH 2/2] Dockerfile: Install special build dependencies for linux/arm/v7 --- Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 74a1eff..9ee5636 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,14 @@ FROM python:3.12-alpine LABEL maintainer="Salvoxia " COPY immich_auto_album.py requirements.txt docker/immich_auto_album.sh docker/setup_cron.sh /script/ - -RUN pip install --no-cache-dir -r /script/requirements.txt \ +ARG TARGETPLATFORM +# gcc and musl-dev are required for building requirements for regex python module +RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then apk add gcc musl-dev; fi \ + && pip install --no-cache-dir -r /script/requirements.txt \ && chmod +x /script/setup_cron.sh /script/immich_auto_album.sh \ - && rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* + && rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* \ + && if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then apk del gcc musl-dev; fi + ENV IS_DOCKER=1 WORKDIR /script CMD ["sh", "-c", "/script/setup_cron.sh && crond -f"] \ No newline at end of file