services: postgres: image: docker.io/library/postgres:16-alpine # Tests hardcode host=localhost port=5433, so postgres listens on 5433 # internally and the tests container joins its network namespace below. command: ["postgres", "-p", "5433"] environment: POSTGRES_DB: broker_test POSTGRES_USER: user POSTGRES_PASSWORD: password ports: - "5434:5433" healthcheck: test: ["CMD-SHELL", "pg_isready -U user -d broker_test -p 5433"] interval: 2s timeout: 3s retries: 30 tests: build: context: . dockerfile: Dockerfile.test network_mode: "service:postgres" depends_on: postgres: condition: service_healthy