From 209efc31b24e88b3605de8b2fd96e218c409323e Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sat, 15 Aug 2026 00:59:05 +0200 Subject: [PATCH] 147 - Run CI in a prebuilt image instead of installing PHP each run --- .forgejo/workflows/ci.yml | 9 +------ .forgejo/workflows/images.yml | 44 +++++++++++++++++++++++++++++++++++ docker/build/Dockerfile.ci | 25 ++++++++++++++++++++ 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 .forgejo/workflows/images.yml create mode 100644 docker/build/Dockerfile.ci diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 90b25726..7e98af9c 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -10,17 +10,10 @@ jobs: ci: runs-on: docker container: - image: catthehacker/ubuntu:act-latest + image: forge.lvl0.xyz/lvl0/fedi-feed-router-ci:latest steps: - uses: https://data.forgejo.org/actions/checkout@v4 - - name: Set up PHP - uses: https://github.com/shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: pdo_sqlite, mbstring, xml, dom - coverage: none - - name: Cache Composer dependencies uses: https://data.forgejo.org/actions/cache@v4 with: diff --git a/.forgejo/workflows/images.yml b/.forgejo/workflows/images.yml new file mode 100644 index 00000000..2bdd4009 --- /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: fedi-feed-router-base + file: docker/build/Dockerfile.base + - name: fedi-feed-router-ci + file: docker/build/Dockerfile.ci + 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 }}:latest + forge.lvl0.xyz/lvl0/${{ matrix.name }}:${{ github.sha }} diff --git a/docker/build/Dockerfile.ci b/docker/build/Dockerfile.ci new file mode 100644 index 00000000..05481602 --- /dev/null +++ b/docker/build/Dockerfile.ci @@ -0,0 +1,25 @@ +# Image for CI: PHP and 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. +# +# Extensions here are the ext-* requirements from composer.lock that php:alpine +# does not already bundle. Regenerate that list before changing this file. +FROM php:8.3-alpine + +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 \ + iconv \ + pcntl \ + posix + +# nodejs is not used by the app's tests; the Forgejo/GitHub JavaScript actions +# (checkout, cache) are executed with it inside this container. +RUN apk add --no-cache git unzip nodejs + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer