From 625291b4bf1f5cb71d033c55a4d71f89f9bbb6bd Mon Sep 17 00:00:00 2001 From: Matthew Northcott Date: Wed, 29 Mar 2023 16:40:45 +1300 Subject: [PATCH] Update docker-compose - add healthcheck to celery - update redis - update healthcheck for postgres --- docker-compose.production.yaml | 21 ++++++++++++++------- docker-compose.yaml | 29 +++++++++++++++++++---------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/docker-compose.production.yaml b/docker-compose.production.yaml index 6aae0bd..bf94e3d 100644 --- a/docker-compose.production.yaml +++ b/docker-compose.production.yaml @@ -6,11 +6,6 @@ volumes: x-django: &django image: right-tree - depends_on: - postgres: - condition: service_healthy - redis: - condition: service_healthy env_file: .env user: "$UID:$GID" restart: always @@ -25,6 +20,13 @@ services: - gunicorn - --bind=0.0.0.0:8000 - right_tree.wsgi + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + celery: + condition: service_healthy nginx: container_name: nginx @@ -54,13 +56,13 @@ services: - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} healthcheck: - test: ["CMD", "pg_isready", "--dbname", "righttree", "--username", "righttree"] + test: ["CMD", "pg_isready", "--dbname", "$DATABASE_NAME", "--username", "$DATABASE_USER"] interval: 10s timeout: 5s retries: 5 redis: - image: redis:7.0.8 + image: redis:7.0.10 restart: always container_name: redis expose: @@ -84,6 +86,11 @@ services: condition: service_healthy redis: condition: service_healthy + healthcheck: + test: ["CMD", "celery", "-A", "right_tree.api", "inspect", "ping"] + interval: 10s + timeout: 5s + retries: 5 deploy: resources: limits: diff --git a/docker-compose.yaml b/docker-compose.yaml index 905e5eb..28143a6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,11 +6,6 @@ volumes: x-django: &django image: right-tree - depends_on: - postgres: - condition: service_healthy - redis: - condition: service_healthy volumes: - ./backend:/app env_file: .env @@ -21,6 +16,13 @@ services: backend: <<: *django container_name: backend + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + celery: + condition: service_healthy expose: - "8000" command: @@ -56,7 +58,7 @@ services: environment: POSTGRES_PASSWORD: postgres healthcheck: - test: ["CMD", "pg_isready", "--dbname", "righttree", "--username", "righttree"] + test: ["CMD", "pg_isready", "--dbname", "$DATABASE_NAME", "--username", "$DATABASE_USER"] interval: 10s timeout: 5s retries: 5 @@ -75,7 +77,7 @@ services: - 80:80 redis: - image: redis:7.0.8 + image: redis:7.0.10 restart: unless-stopped container_name: redis volumes: @@ -94,14 +96,21 @@ services: celery: <<: *django container_name: celery + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy command: - celery - -A - right_tree.api - worker - depends_on: - redis: - condition: service_healthy + healthcheck: + test: ["CMD", "celery", "-A", "right_tree.api", "inspect", "ping"] + interval: 10s + timeout: 5s + retries: 5 deploy: resources: limits: