From abac8509cb64c7a13362ddacc03cfb0d42d5814a Mon Sep 17 00:00:00 2001 From: myrmidex Date: Mon, 17 Aug 2026 14:00:02 +0200 Subject: [PATCH] 46 - Add CI image and app image build workflows --- .forgejo/workflows/build.yml | 42 +++++++++++++++++++++++++++++++++ .forgejo/workflows/images.yml | 44 +++++++++++++++++++++++++++++++++++ .gitattributes | 2 -- docker/build/Dockerfile.ci | 30 ++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 .forgejo/workflows/build.yml create mode 100644 .forgejo/workflows/images.yml create mode 100644 docker/build/Dockerfile.ci diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml new file mode 100644 index 0000000..ee637de --- /dev/null +++ b/.forgejo/workflows/build.yml @@ -0,0 +1,42 @@ +name: Build and Push Docker Image + +on: + push: + branches: [main] + tags: ['v*'] + +jobs: + build: + runs-on: docker + container: + image: catthehacker/ubuntu:act-latest + steps: + - uses: https://data.forgejo.org/actions/checkout@v4 + + - name: Set up Docker Buildx + uses: https://data.forgejo.org/docker/setup-buildx-action@v3 + + - name: Login to Forgejo Registry + uses: https://data.forgejo.org/docker/login-action@v3 + with: + registry: forge.lvl0.xyz + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Determine tags + id: meta + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + TAG="${{ github.ref_name }}" + echo "tags=forge.lvl0.xyz/lvl0/dishplanner:${TAG},forge.lvl0.xyz/lvl0/dishplanner:latest" >> $GITHUB_OUTPUT + else + echo "tags=forge.lvl0.xyz/lvl0/dishplanner:latest" >> $GITHUB_OUTPUT + fi + + - name: Build and push + uses: https://data.forgejo.org/docker/build-push-action@v5 + with: + context: . + file: Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.forgejo/workflows/images.yml b/.forgejo/workflows/images.yml new file mode 100644 index 0000000..37ec313 --- /dev/null +++ b/.forgejo/workflows/images.yml @@ -0,0 +1,44 @@ +name: Build and Push Base Images + +on: + push: + branches: [main] + paths: + - 'docker/build/**' + - '.forgejo/workflows/images.yml' + workflow_dispatch: + +jobs: + images: + runs-on: docker + container: + image: catthehacker/ubuntu:act-latest + strategy: + matrix: + include: + - name: dishplanner-ci + file: docker/build/Dockerfile.ci + version: php8.3-1 + steps: + - uses: https://data.forgejo.org/actions/checkout@v4 + + - name: Set up Docker Buildx + uses: https://data.forgejo.org/docker/setup-buildx-action@v3 + + - name: Login to Forgejo Registry + uses: https://data.forgejo.org/docker/login-action@v3 + with: + registry: forge.lvl0.xyz + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Build and push + uses: https://data.forgejo.org/docker/build-push-action@v5 + with: + context: . + file: ${{ matrix.file }} + push: true + tags: | + forge.lvl0.xyz/lvl0/${{ matrix.name }}:${{ matrix.version }} + forge.lvl0.xyz/lvl0/${{ matrix.name }}:latest + forge.lvl0.xyz/lvl0/${{ matrix.name }}:${{ github.sha }} diff --git a/.gitattributes b/.gitattributes index fcb21d3..1d7f82b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,6 +6,4 @@ *.md diff=markdown *.php diff=php -/.github export-ignore CHANGELOG.md export-ignore -.styleci.yml export-ignore diff --git a/docker/build/Dockerfile.ci b/docker/build/Dockerfile.ci new file mode 100644 index 0000000..3c3c5ec --- /dev/null +++ b/docker/build/Dockerfile.ci @@ -0,0 +1,30 @@ +# CI image: PHP + Composer only, no runtime server or frontend toolchain. +# Tests run against SQLite in memory (see .env.testing), so no database client +# or cache extension is needed. +# +# Published as dishplanner-ci:php8.3-. Bump the revision in the tag +# and in .forgejo/workflows/ci.yml whenever this file changes (runners cache +# mutable tags and will not re-pull them). +# +# Debian-based rather than Alpine to avoid the DNS resolution timeouts against +# codeload.github.com that the Alpine base hit during composer install. + +FROM php:8.3-cli + +COPY --from=mlocati/php-extension-installer:2 /usr/bin/install-php-extensions /usr/local/bin/ + +RUN install-php-extensions \ + pdo_sqlite \ + mbstring \ + dom \ + xml \ + fileinfo \ + pcntl + +# git is needed by the checkout action; nodejs runs the Forgejo JavaScript +# actions (checkout, cache); unzip lets Composer extract dist archives. +RUN apt-get update \ + && apt-get install -y --no-install-recommends git unzip nodejs \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer