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:
2026-05-10 22:52:14 +00:00
parent 22e8717e0c
commit e4a77fdea3

View File

@@ -114,33 +114,26 @@ jobs:
api-integration: api-integration:
name: API Integration Tests name: API Integration Tests
runs-on: ubuntu-latest 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: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Start MinIO - name: Start services
run: | 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 \ docker run -d --name ci-minio \
--network container:$(hostname) \ --network container:$(hostname) \
-e MINIO_ROOT_USER=minioadmin \ -e MINIO_ROOT_USER=minioadmin \
-e MINIO_ROOT_PASSWORD=minioadmin \ -e MINIO_ROOT_PASSWORD=minioadmin \
quay.io/minio/minio server /data quay.io/minio/minio server /data
- name: Create MinIO bucket - name: Wait for services and create bucket
run: | 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 curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /tmp/mc
chmod +x /tmp/mc chmod +x /tmp/mc
until /tmp/mc alias set local http://localhost:9000 minioadmin minioadmin; do sleep 2; done until /tmp/mc alias set local http://localhost:9000 minioadmin minioadmin; do sleep 2; done
@@ -178,9 +171,9 @@ jobs:
OWNER_USERNAME: testowner OWNER_USERNAME: testowner
OWNER_PASSWORD: testpass OWNER_PASSWORD: testpass
- name: Stop MinIO - name: Stop services
if: always() 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) ──────────────────────────────── # ── Image builds (tag-only, gated on all jobs) ────────────────────────────────