diff --git a/.github/workflows/build_postgres_image.yml b/.github/workflows/build_postgres_image.yml new file mode 100644 index 0000000000..38a57a9231 --- /dev/null +++ b/.github/workflows/build_postgres_image.yml @@ -0,0 +1,54 @@ +name: Postgres image for CI + +on: + # Run daily at 00:00 UTC. This allows the image to pick up updates from upstream and avoid + # going stale. + schedule: + - cron: '0 0 * * 0' + # Allow manual triggering + workflow_dispatch: + +jobs: + build_image: + name: 'Build postgres:${{ matrix.postgres_version }}-alpine-logical' + runs-on: ubuntu-latest + + permissions: + packages: write + + strategy: + matrix: + # The same versions are used by elixir_tests.yml + postgres_version: [14, 15, 17, 18] + + steps: + - name: Set image ref + id: vars + run: | + echo "IMAGE=ghcr.io/${{ github.repository }}/postgres" >> $GITHUB_ENV + + - name: Login to GHCR (private) + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up buildx for advanced Docker caching + uses: docker/setup-buildx-action@v3 + + - name: Prepare the Dockerfile + run: | + echo ' + FROM postgres:${{ matrix.postgres_version }}-alpine + CMD ["postgres", "-c", "wal_level=logical", "-c", "max_replication_slots=40"] + ' > Dockerfile + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: '${{ env.IMAGE }}:${{ matrix.postgres_version }}-alpine-logical' + cache-from: type=gha + cache-to: type=gha,mode=max