Skip to content

Commit

Permalink
chore: add docker-compose healthcheck for postgres (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlugter authored Aug 8, 2023
1 parent 638c8db commit 2f6732b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down Expand Up @@ -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: |-
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

```
Expand Down
7 changes: 7 additions & 0 deletions docker/docker-compose-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions docs/src/main/paradox/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 2f6732b

Please sign in to comment.