AMI: Clean up messy apt handling #1788
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Image Test | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| push: | |
| branches: | |
| - develop | |
| - release/* | |
| workflow_call: | |
| secrets: | |
| DEV_AWS_ROLE: | |
| required: true | |
| NIX_SIGN_SECRET_KEY: | |
| required: true | |
| workflow_dispatch: | |
| inputs: | |
| dockerfile: | |
| description: 'Specific Dockerfile to test (leave empty for all)' | |
| required: false | |
| default: '' | |
| type: string | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| check-changes: | |
| name: Check Docker Image Changes | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| outputs: | |
| should_run: ${{ steps.check.outputs.should_run }} | |
| input_hash: ${{ steps.check.outputs.input_hash }} | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Install nix | |
| uses: ./.github/actions/nix-install-ephemeral | |
| - name: Check Docker image changes | |
| id: check | |
| uses: ./.github/actions/check-docker-image-changes | |
| with: | |
| event_name: ${{ github.event_name }} | |
| base_ref: ${{ github.base_ref }} | |
| docker-image-test: | |
| name: Test ${{ matrix.name }} | |
| needs: check-changes | |
| if: needs.check-changes.outputs.should_run == 'true' | |
| runs-on: large-linux-arm | |
| timeout-minutes: 120 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # CHANGED: Dockerfile-15/17 replaced by parameterised Dockerfile-supabase. | |
| # pg_version is passed as --build-arg PG_VERSION to select the PostgreSQL version. | |
| - dockerfile: Dockerfile-supabase | |
| name: 15 | |
| pg_version: "15" | |
| - dockerfile: Dockerfile-supabase | |
| name: 17 | |
| pg_version: "17" | |
| - dockerfile: Dockerfile-orioledb-17 | |
| name: orioledb-17 | |
| pg_version: "17" | |
| # CHANGED: base_dockerfile causes the build step to build the supabase base image | |
| # locally first and pass it as SUPABASE_IMAGE. The variant-orioledb-17 entry was | |
| # removed — that target does not exist in Dockerfile-multigres. | |
| - dockerfile: Dockerfile-multigres | |
| name: multigres-17 | |
| pg_version: "17" | |
| base_dockerfile: Dockerfile-supabase | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Install nix | |
| uses: ./.github/actions/nix-install-ephemeral | |
| - name: Create Docker context | |
| run: docker context create builders | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 | |
| with: | |
| endpoint: builders | |
| - name: Build Docker image | |
| run: | | |
| echo "Building ${{ matrix.name }}..." | |
| # CHANGED: pass PG_VERSION for Dockerfile-supabase and Dockerfile-multigres builds. | |
| PG_VERSION_ARG="" | |
| if [ -n "${{ matrix.pg_version }}" ]; then | |
| PG_VERSION_ARG="--build-arg PG_VERSION=${{ matrix.pg_version }}" | |
| fi | |
| # CHANGED: layered images (multigres) need their base image available locally. | |
| # Each matrix job runs on an isolated runner, so we build the base inline here | |
| # and pass it as SUPABASE_IMAGE rather than pulling from a registry. | |
| BASE_IMAGE_ARG="" | |
| if [ -n "${{ matrix.base_dockerfile }}" ]; then | |
| docker build -f "${{ matrix.base_dockerfile }}" \ | |
| --build-arg PG_VERSION=${{ matrix.pg_version }} \ | |
| --target production \ | |
| -t "pg-docker-test:base-${{ matrix.name }}" \ | |
| . | |
| BASE_IMAGE_ARG="--build-arg SUPABASE_IMAGE=pg-docker-test:base-${{ matrix.name }}" | |
| fi | |
| docker build -f "${{ matrix.dockerfile }}" --target production $PG_VERSION_ARG $BASE_IMAGE_ARG \ | |
| -t "pg-docker-test:${{ matrix.name }}" \ | |
| -t "supabase-postgres:${{ matrix.name }}-analyze" \ | |
| . | |
| - name: Run image size analysis | |
| if: ${{ matrix.base_dockerfile == '' }} | |
| run: | | |
| echo "=== Image Size Analysis for ${{ matrix.name }} ===" | |
| nix run --accept-flake-config .#image-size-analyzer -- --image ${{ matrix.dockerfile }} --pg-version ${{ matrix.pg_version }} --no-build | |
| - name: Run Docker image tests | |
| if: ${{ matrix.base_dockerfile == '' }} | |
| run: | | |
| echo "=== Running tests for ${{ matrix.name }} ===" | |
| nix run --accept-flake-config .#docker-image-test -- --no-build --pg-version ${{ matrix.pg_version }} ${{ matrix.dockerfile }} | |
| - name: Run multigres Docker image tests | |
| if: ${{ matrix.base_dockerfile != '' }} | |
| run: | | |
| echo "=== Running tests for ${{ matrix.name }} ===" | |
| nix run --accept-flake-config .#docker-image-test -- --no-build --target production ${{ matrix.dockerfile }} | |
| - name: Show container logs on failure | |
| if: failure() | |
| run: | | |
| CONTAINER_NAME=$(docker ps -a --filter "name=pg-test-${{ matrix.name }}" --format "{{.Names}}" | head -1) | |
| if [[ -n "$CONTAINER_NAME" ]]; then | |
| echo "=== Container logs for $CONTAINER_NAME ===" | |
| docker logs "$CONTAINER_NAME" 2>&1 || true | |
| fi | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| docker ps -a --filter "name=pg-test-${{ matrix.name }}" -q | xargs -r docker rm -f || true | |
| docker rmi "pg-docker-test:${{ matrix.name }}" || true | |
| docker rmi "pg-docker-test:base-${{ matrix.name }}" || true # CHANGED: remove ephemeral base image built for layered builds | |
| docker rmi "supabase-postgres:${{ matrix.name }}-analyze" || true | |
| skip-notification: | |
| name: Docker Image Test (Skipped) | |
| needs: check-changes | |
| if: needs.check-changes.outputs.should_run == 'false' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Report skipped | |
| run: | | |
| echo "Docker image tests skipped - inputs unchanged" | |
| echo "Input hash: ${{ needs.check-changes.outputs.input_hash }}" |