From 9e8dd9bf2fa870f8dea39b7edc025e64e38bd51d Mon Sep 17 00:00:00 2001 From: Nikolai Papin Date: Tue, 17 Jun 2025 22:20:49 +0300 Subject: [PATCH] feat: healthchecks for postgres, redis, minio; feat: backend container now depends on postgres, redis and minio (must be healthy); feat: frontend depends on backend being healthy --- docker-compose.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f5ff876..fd1991b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,16 @@ services: backend: build: ./backend restart: unless-stopped + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + minio: + condition: service_healthy healthcheck: test: ["CMD", "/usr/bin/curl", "-f", "http://localhost:8080/service/health"] - interval: 30s + interval: 5s timeout: 10s retries: 3 ports: @@ -16,11 +23,19 @@ services: frontend: build: ./frontend restart: unless-stopped + depends_on: + backend: + condition: service_healthy networks: - easywish-network minio: image: minio/minio + healthcheck: + test: [ "CMD", "curl", "-I", "localhost:9000/minio/health/live" ] + interval: 5s + timeout: 10s + retries: 3 environment: MINIO_ROOT_USER: ${MINIO_ROOT_USER} MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD} @@ -34,6 +49,11 @@ services: postgres: image: postgres:latest + healthcheck: + test: [ "CMD", "pg_isready", "-q", "-d", "${POSTGRES_DB}", "-U", "${POSTGRES_USER}" ] + interval: 5s + timeout: 10s + retries: 3 environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} @@ -48,6 +68,11 @@ services: redis: image: eqalpha/keydb + healthcheck: + test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ] + interval: 5s + timeout: 10s + retries: 3 command: ["keydb-server", "--requirepass", "${REDIS_PASSWORD}"] environment: REDIS_PASSWORD: ${REDIS_PASSWORD}