Skip to content

Commit c6becf3

Browse files
authored
Add a CI job to test that running Electric using a Docker image works (#2762)
We've had a couple of commits in the past where Electric was working fine in dev but ended up failing on startup when run as a Docker container. This CI job is designed to verify that Electric starts up and reaches healthy state when running inside a container.
1 parent 18e9a7a commit c6becf3

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Electric Docker Image Smoke Test
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- "**/README.md"
7+
8+
jobs:
9+
docker_image_smoketest:
10+
name: Docker image smoke test
11+
runs-on: ubuntu-latest
12+
services:
13+
postgres:
14+
image: "postgres:17-alpine"
15+
env:
16+
POSTGRES_PASSWORD: password
17+
ports:
18+
- 5432:5432
19+
20+
steps:
21+
- name: "Set PG settings"
22+
run: |
23+
docker exec ${{ job.services.postgres.id }} sh -c 'echo "wal_level=logical" >> /var/lib/postgresql/data/postgresql.conf'
24+
docker restart ${{ job.services.postgres.id }}
25+
26+
- uses: docker/setup-buildx-action@v3
27+
28+
- uses: actions/checkout@v4
29+
30+
- uses: docker/build-push-action@v6
31+
with:
32+
context: packages/sync-service
33+
push: false
34+
load: true
35+
tags: "electric-test-image"
36+
cache-from: type=gha
37+
cache-to: type=gha,mode=max
38+
39+
- name: "Run the built image"
40+
run: |
41+
docker run \
42+
--rm \
43+
--net host \
44+
--name electric \
45+
-e ELECTRIC_USAGE_REPORTING=false \
46+
-e ELECTRIC_INSECURE=true \
47+
-e DATABASE_URL='postgresql://postgres:password@localhost:5432?sslmode=disable' \
48+
-d \
49+
electric-test-image
50+
51+
- name: Wait for the container to reach healthy status
52+
uses: stringbean/docker-healthcheck-action@v3
53+
with:
54+
container: electric
55+
require-status: running
56+
require-healthy: true
57+
wait-time: 20
58+
59+
- name: Dump container logs
60+
run: docker logs electric

0 commit comments

Comments
 (0)