diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index b443d68c..0d211c0d 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -67,10 +67,8 @@ jobs: - name: Start DB run: |- - docker-compose -f docker/docker-compose-postgres.yml up -d - # TODO: could we poll the port instead of sleep? - sleep 10 - docker exec -i docker_postgres-db_1 psql -U postgres -t < ddl-scripts/create_tables_postgres.sql + docker compose -f docker/docker-compose-postgres.yml up --wait + docker exec -i postgres-db psql -U postgres -t < ddl-scripts/create_tables_postgres.sql - name: sbt test run: |- @@ -103,10 +101,8 @@ jobs: - name: Start DB run: |- - docker-compose -f docker/docker-compose-postgres.yml up -d - # TODO: could we poll the port instead of sleep? - sleep 10 - docker exec -i docker_postgres-db_1 psql -U postgres -t < ddl-scripts/create_tables_postgres_jsonb.sql + docker compose -f docker/docker-compose-postgres.yml up --wait + docker exec -i postgres-db psql -U postgres -t < ddl-scripts/create_tables_postgres_jsonb.sql - name: sbt test run: |- diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f31cc214..7f983514 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -41,10 +41,8 @@ jobs: - name: Start DB run: |- - docker-compose -f docker/docker-compose-postgres.yml up -d - # TODO: could we poll the port instead of sleep? - sleep 10 - docker exec -i docker_postgres-db_1 psql -U postgres -t < ddl-scripts/create_tables_postgres.sql + docker compose -f docker/docker-compose-postgres.yml up --wait + docker exec -i postgres-db psql -U postgres -t < ddl-scripts/create_tables_postgres.sql - name: sbt ${{ matrix.testCmd }} run: |- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a266eb22..328d3caf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,17 +7,17 @@ The tests expect a locally running database. It can be started with the docker-compose file in the docker folder: ``` -docker-compose -f docker/docker-compose-postgres.yml up +docker-compose -f docker/docker-compose-postgres.yml up --wait ``` ``` -docker exec -i docker_postgres-db_1 psql -U postgres -t < ddl-scripts/create_tables_postgres.sql +docker exec -i postgres-db psql -U postgres -t < ddl-scripts/create_tables_postgres.sql ``` ## Some useful debug queries for Postgres ``` -docker exec -it docker_postgres-db_1 psql -U postgres +docker exec -it postgres-db psql -U postgres ``` ``` diff --git a/docker/docker-compose-postgres.yml b/docker/docker-compose-postgres.yml index 0aabd6a7..0c70331f 100644 --- a/docker/docker-compose-postgres.yml +++ b/docker/docker-compose-postgres.yml @@ -2,8 +2,15 @@ version: '2.2' services: postgres-db: image: postgres:latest + container_name: postgres-db ports: - 5432:5432 environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + healthcheck: + test: ['CMD', 'pg_isready', "-q", "-d", "postgres", "-U", "postgres"] + interval: 5s + retries: 5 + start_period: 5s + timeout: 5s diff --git a/docs/src/main/paradox/getting-started.md b/docs/src/main/paradox/getting-started.md index 4e321d87..a72c74d0 100644 --- a/docs/src/main/paradox/getting-started.md +++ b/docs/src/main/paradox/getting-started.md @@ -113,7 +113,7 @@ Start with: Postgres: : ``` -docker-compose -f docker/docker-compose-postgres.yml up +docker-compose -f docker/docker-compose-postgres.yml up --wait ``` Yugabyte: @@ -139,7 +139,7 @@ The ddl script can be run in Docker with: Postgres: : ``` -docker exec -i docker_postgres-db_1 psql -U postgres -t < ddl-scripts/create_tables_postgres.sql +docker exec -i postgres-db psql -U postgres -t < ddl-scripts/create_tables_postgres.sql ``` Yugabyte: