diff --git a/docker-compose.yml b/docker-compose.yml index e865ac8..4c951a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,11 @@ services: - 5432:5432 volumes: - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] + interval: 5s + timeout: 5s + retries: 5 redis: image: redis:latest @@ -31,8 +36,12 @@ services: REDIS_HOST: ${REDIS_HOST} REDIS_PORT: ${REDIS_PORT} depends_on: - - db - - redis + db: + condition: service_healthy + redis: + condition: service_started + restart: on-failure + # if the API down in the timing when postgres is connecting, restart automatically celery_worker: build: . @@ -45,8 +54,10 @@ services: REDIS_HOST: ${REDIS_HOST} REDIS_PORT: ${REDIS_PORT} depends_on: - - db - - redis + db: + condition: service_healthy + redis: + condition: service_started command: celery -A celery_app worker celery_beat: @@ -60,8 +71,10 @@ services: REDIS_HOST: ${REDIS_HOST} REDIS_PORT: ${REDIS_PORT} depends_on: - - db - - redis + db: + condition: service_healthy + redis: + condition: service_started command: celery -A celery_app beat prometheus: