graphql-engine/v3/ci.docker-compose.yaml
Samir Talwar e931a391eb Various improvements to the Docker Compose services. (#383)
I got frustrated by the lack of useful output when services failed to
start in CI, so I thought I'd mess around.

I made some changes so that:

1. we wait for services with health checks to report as healthy,
2. we do not rebuild the engine or custom connector when they start,
3. the health checks work (apart from ndc-postgres, which will come
later), and
4. we use environment variables rather than command-line arguments where
possible.

I have also renamed the "agent" binary to "custom-connector", matching
its crate, because it was driving me a little crazy.

V3_GIT_ORIGIN_REV_ID: 8d672b0b25438b54d47368ce82cd236cfdd4e554
2024-03-21 16:49:38 +00:00

95 lines
2.5 KiB
YAML

version: "3.9"
services:
postgres:
image: postgis/postgis:16-3.4
platform: linux/amd64
command:
- -F # turn fsync off for speed
- -N 1000 # increase max connections from 100 so we can run more HGEs
environment:
POSTGRES_PASSWORD: "password"
volumes:
- type: volume
source: postgres
target: /var/lib/postgresql/data
- type: bind
source: ./crates/engine/tests/db_definition.sql
target: /docker-entrypoint-initdb.d/db_definition.sql
read_only: true
healthcheck:
test:
- CMD-SHELL
- psql -U "$${POSTGRES_USER:-postgres}" < /dev/null && sleep 5 && psql -U "$${POSTGRES_USER:-postgres}" < /dev/null
start_period: 5s
interval: 5s
timeout: 10s
retries: 20
postgres_connector:
image: ghcr.io/hasura/ndc-postgres:dev-main-0452625e7
command:
- serve
- --configuration
- /config.json
ports:
- "8100:8100"
volumes:
- ./crates/engine/tests/pg_ndc_config.json:/config.json
depends_on:
postgres:
condition: service_healthy
custom_connector:
build:
context: .
target: built
entrypoint:
- ./target/release/custom-connector
ports:
- "8101:8101"
healthcheck:
test: curl -fsS http://localhost:8101/schema
start_period: 5s
interval: 5s
timeout: 10s
retries: 20
source_only:
build:
context: .
target: builder
volumes:
# So that updated files make their way back to the host machine
- ./tracing-util:/app/tracing-util
- ./lang-graphql:/app/lang-graphql
- ./open-dds:/app/open-dds
- ./engine:/app/engine
- ./hasura-authn-core:/app/hasura-authn-core
- ./hasura-authn-webhook:/app/hasura-authn-webhook
- ./coverage:/app/coverage
test_setup:
build:
context: .
target: builder
depends_on:
postgres:
condition: service_healthy
postgres_connector:
condition: service_started
custom_connector:
condition: service_healthy
volumes:
# So that updated files make their way back to the host machine
- ./tracing-util:/app/tracing-util
- ./lang-graphql:/app/lang-graphql
- ./open-dds:/app/open-dds
- ./engine:/app/engine
- ./hasura-authn-core:/app/hasura-authn-core
- ./hasura-authn-webhook:/app/hasura-authn-webhook
- ./benchmark.sh:/app/benchmark.sh
- ./coverage:/app/coverage
volumes:
postgres: