Skip to content

Commit

Permalink
fix(dev-environment): Wait for Postgres to fully initialise
Browse files Browse the repository at this point in the history
Configure a healthcheck on the Postgres container, passing only once the initialisation scripts have completed.

This fixes the behaviour where CloudQuery would fail stating:

```log
failed to init destination postgresql: rpc error: code = Internal desc = failed to init plugin: failed to initialize client: failed to get current database: failed to connect to `host=postgres user=postgres database=postgres`: dial error (dial tcp 172.26.0.2:5432: connect: connection refused)
```
  • Loading branch information
akash1810 committed May 24, 2024
1 parent a94b48f commit e8bdcdc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/dev-environment/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,21 @@ services:
depends_on:
db-copy:
condition: service_completed_successfully
healthcheck:
# Ensures the initialisation scripts have completed, before accepting connections from CloudQuery, Grafana, etc.
test: [ "CMD-SHELL", "pg_isready --host 127.0.0.1" ]
interval: 10s
timeout: 5s
retries: 5
cloudquery:
build:
context: ../../containers/cloudquery
args:
CQ_CLI: ${CQ_CLI}
platform: linux/amd64
depends_on:
- postgres
postgres:
condition: service_healthy
volumes:
- ~/.aws/credentials:/.aws/credentials
- ./config/cloudquery.yaml:/cloudquery.yaml
Expand Down Expand Up @@ -82,7 +89,8 @@ services:
grafana_version: ${GRAFANA_VERSION:-10.3.3}
development: ${DEVELOPMENT:-true}
depends_on:
- postgres
postgres:
condition: service_healthy
ports:
- '3000:3000'
volumes:
Expand Down

0 comments on commit e8bdcdc

Please sign in to comment.