From e4a77fdea362db89a01400e45539f5753a5440c1 Mon Sep 17 00:00:00 2001 From: agatha Date: Sun, 10 May 2026 22:52:14 +0000 Subject: [PATCH] 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 --- .gitea/workflows/pipeline.yml | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 9dd01bd..d086549 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -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) ────────────────────────────────