feat: Add health checks for frontend, API, and database services in Docker Compose

This commit is contained in:
Nils-Johan Gynther
2026-04-14 22:39:06 +02:00
parent a118a2ff11
commit f50b4901f5
+23 -8
View File
@@ -3,12 +3,18 @@ services:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: recipe-frontend
restart: unless-stopped
environment:
NEXT_PUBLIC_API_URL: "http://recipe-api:8080"
# env_file:
# - .env
depends_on:
recipe-api:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3000 >/dev/null 2>&1 || exit 1"]
interval: 20s
timeout: 10s
retries: 5
start_period: 40s
networks:
- proxy
- recipe-internal
@@ -18,22 +24,25 @@ services:
context: ./backend
dockerfile: Dockerfile
image: recipe-api:local
container_name: recipe-api
restart: unless-stopped
environment:
DATABASE_URL: "mysql://root:${MARIADB_ROOT_PASSWORD}@recipe-db:3306/${MARIADB_DATABASE}"
depends_on:
- recipe-db
recipe-db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:8080/api/health >/dev/null 2>&1 || exit 1"]
interval: 20s
timeout: 10s
retries: 10
start_period: 40s
networks:
- proxy
- recipe-internal
recipe-db:
image: mariadb:11
container_name: recipe-db
restart: unless-stopped
# env_file:
# - .env
environment:
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
MARIADB_DATABASE: ${MARIADB_DATABASE}
@@ -45,6 +54,12 @@ services:
command: >
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
healthcheck:
test: ["CMD-SHELL", "mariadb-admin ping -h 127.0.0.1 -uroot -p$$MARIADB_ROOT_PASSWORD >/dev/null 2>&1 || exit 1"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
networks:
- recipe-internal