safe-global / safe-infrastructure

One `docker-compose.yml` file to rule them all
MIT License
56 stars 92 forks source link

Update Docker Compose file to improve service startup dependencies #104

Closed mshakeg closed 1 year ago

mshakeg commented 1 year ago

Upon working with the current docker-compose.yml, I have noticed that some services are starting before their dependencies are ready. This leads to initial startup failures and makes the docker-compose process less reliable.

Specifically, I observed that services depending on the Redis instances and PostgreSQL databases were starting before these dependencies were fully initialized. Additionally, the PostgreSQL services (txs-db and cfg-db) did not have health checks, which is necessary for reliably determining when these services are ready to accept connections.

To address these problems, I propose the following changes:

  1. Add health checks to the txs-db and cfg-db services, using the pg_isready -U postgres command to determine if the PostgreSQL servers are accepting connections.
  2. Add the service_healthy condition to all services that depend on txs-db or cfg-db, to ensure they only start after the databases are ready.
  3. Add a health check to the txs-redis and cgw-redis services, using the redis-cli ping command to determine if the Redis server is up.
  4. Add the service_healthy condition to all services that depend on txs-redis and cgw-redis, to ensure they only start after Redis is ready.