Skip to content

Commit af92800

Browse files
committed
Build Postgres images preconfigured with logical replication for use in CI workflows
1 parent 4a74617 commit af92800

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Postgres image for CI
2+
3+
on:
4+
# Run daily at 00:00 UTC. This allows the image to pick up updates from upstream and avoid
5+
# going stale.
6+
schedule:
7+
- cron: '0 0 * * 0'
8+
# Allow manual triggering
9+
workflow_dispatch:
10+
11+
jobs:
12+
build_image:
13+
name: 'Build postgres:${{ matrix.postgres_version }}-alpine-logical'
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
packages: write
18+
19+
strategy:
20+
matrix:
21+
# The same versions are used by elixir_tests.yml
22+
postgres_version: [14, 15, 17, 18]
23+
24+
steps:
25+
- name: Set image ref
26+
id: vars
27+
run: |
28+
echo "IMAGE=ghcr.io/${{ github.repository }}/postgres" >> $GITHUB_ENV
29+
30+
- name: Login to GHCR (private)
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Set up buildx for advanced Docker caching
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Prepare the Dockerfile
41+
run: |
42+
echo '
43+
FROM postgres:${{ matrix.postgres_version }}-alpine
44+
CMD ["postgres", "-c", "wal_level=logical", "-c", "max_replication_slots=40"]
45+
' > Dockerfile
46+
47+
- name: Build and push
48+
uses: docker/build-push-action@v6
49+
with:
50+
context: .
51+
push: true
52+
tags: '${{ env.IMAGE }}:${{ matrix.postgres_version }}-alpine-logical'
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)