CI: Move Postgres to manual docker run with shared network namespace
Service containers bind ports to the host, not to localhost inside the job container. Start both Postgres and MinIO manually with --network container:$(hostname) so they share the job container's network namespace and are reachable on localhost. Use docker exec for pg_isready to avoid depending on postgresql-client in the runner image. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -114,33 +114,26 @@ jobs:
|
||||
api-integration:
|
||||
name: API Integration Tests
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16
|
||||
env:
|
||||
POSTGRES_USER: reactbin
|
||||
POSTGRES_PASSWORD: reactbin
|
||||
POSTGRES_DB: reactbin_test
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Start MinIO
|
||||
- name: Start services
|
||||
run: |
|
||||
docker run -d --name ci-postgres \
|
||||
--network container:$(hostname) \
|
||||
-e POSTGRES_USER=reactbin \
|
||||
-e POSTGRES_PASSWORD=reactbin \
|
||||
-e POSTGRES_DB=reactbin_test \
|
||||
postgres:16
|
||||
docker run -d --name ci-minio \
|
||||
--network container:$(hostname) \
|
||||
-e MINIO_ROOT_USER=minioadmin \
|
||||
-e MINIO_ROOT_PASSWORD=minioadmin \
|
||||
quay.io/minio/minio server /data
|
||||
|
||||
- name: Create MinIO bucket
|
||||
- name: Wait for services and create bucket
|
||||
run: |
|
||||
until docker exec ci-postgres pg_isready -U reactbin; do sleep 2; done
|
||||
curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /tmp/mc
|
||||
chmod +x /tmp/mc
|
||||
until /tmp/mc alias set local http://localhost:9000 minioadmin minioadmin; do sleep 2; done
|
||||
@@ -178,9 +171,9 @@ jobs:
|
||||
OWNER_USERNAME: testowner
|
||||
OWNER_PASSWORD: testpass
|
||||
|
||||
- name: Stop MinIO
|
||||
- name: Stop services
|
||||
if: always()
|
||||
run: docker stop ci-minio && docker rm ci-minio || true
|
||||
run: docker stop ci-postgres ci-minio || true && docker rm ci-postgres ci-minio || true
|
||||
|
||||
# ── Image builds (tag-only, gated on all jobs) ────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user