diff --git a/docker-compose.yml b/docker-compose.yml index f39ffb4..099d8b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,20 @@ volumes: nginx-shared-txs: nginx-shared-cfg: +x-healthcheck-db-template: &pghealthcheck + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 30s + timeout: 30s + retries: 3 + +x-healthcheck-redis-template: &redishealthcheck + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 30s + timeout: 30s + retries: 3 + services: # Common nginx and database @@ -26,6 +40,7 @@ services: POSTGRES_PASSWORD: postgres volumes: - ./data/txs-db:/var/lib/postgresql/data + <<: *pghealthcheck cfg-db: image: postgres:14-alpine @@ -33,11 +48,12 @@ services: POSTGRES_PASSWORD: postgres volumes: - ./data/cfg-db:/var/lib/postgresql/data - + <<: *pghealthcheck # Safe Transaction Service txs-redis: image: redis:alpine + <<: *redishealthcheck txs-rabbitmq: image: rabbitmq:alpine @@ -49,8 +65,10 @@ services: environment: - ETHEREUM_NODE_URL=${RPC_NODE_URL} depends_on: - - txs-db - - txs-redis + txs-db: + condition: service_healthy + txs-redis: + condition: service_healthy working_dir: /app volumes: - nginx-shared-txs:/nginx @@ -65,8 +83,10 @@ services: - RUN_MIGRATIONS=1 - WORKER_QUEUES=default,indexing depends_on: - - txs-db - - txs-redis + txs-db: + condition: service_healthy + txs-redis: + condition: service_healthy command: docker/web/celery/worker/run.sh txs-worker-contracts-tokens: @@ -74,15 +94,30 @@ services: environment: - WORKER_QUEUES=contracts,tokens - ETHEREUM_NODE_URL=${RPC_NODE_URL} + depends_on: + txs-db: + condition: service_healthy + txs-redis: + condition: service_healthy txs-worker-notifications-webhooks: <<: *txs-worker environment: - WORKER_QUEUES=notifications,webhooks - ETHEREUM_NODE_URL=${RPC_NODE_URL} + depends_on: + txs-db: + condition: service_healthy + txs-redis: + condition: service_healthy txs-scheduler: <<: *txs-worker + depends_on: + txs-db: + condition: service_healthy + txs-redis: + condition: service_healthy command: docker/web/celery/scheduler/run.sh # Safe Config Service @@ -94,18 +129,21 @@ services: env_file: - container_env_files/cfg.env depends_on: - - cfg-db + cfg-db: + condition: service_healthy # Safe Client Gateway cgw-redis: image: redis:alpine + <<: *redishealthcheck cgw-web: image: safeglobal/safe-client-gateway:${CGW_VERSION} env_file: - container_env_files/cgw.env depends_on: - - cgw-redis + cgw-redis: + condition: service_healthy ui: image: safeglobal/safe-wallet-web:${UI_VERSION}