From 5e3033992460861aa964d426296193142f3f92bb Mon Sep 17 00:00:00 2001 From: Lorenzo Guideri Date: Thu, 7 Nov 2024 11:43:55 +0100 Subject: [PATCH] Added check on container health --- server/docker-compose.yml | 7 ++++++- server/example.env | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/docker-compose.yml b/server/docker-compose.yml index b135cb5..a2086c9 100644 --- a/server/docker-compose.yml +++ b/server/docker-compose.yml @@ -4,7 +4,8 @@ services: ports: - "${HOST_PHP_PORT}:80" depends_on: - - db + db: + condition: service_healthy env_file: - .env @@ -14,6 +15,10 @@ services: - "${HOST_MYSQL_PORT}:${MYSQL_PORT}" env_file: - .env + healthcheck: + test: ["CMD-SHELL", "mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD --execute='SELECT 1;'"] + interval: 5s + retries: 10 volumes: - db_data:/var/lib/mysql diff --git a/server/example.env b/server/example.env index 9f4ab4b..e572bbd 100644 --- a/server/example.env +++ b/server/example.env @@ -7,4 +7,4 @@ export MYSQL_PASSWORD='banana' export MYSQL_ROOT_PASSWORD='banana' export HOST_PHP_PORT=1984 -export HOST_MYSQL_PORT=3306 +export HOST_MYSQL_PORT=3307