From 097a70887b537ef4962735cf5dddac065ccb8fb3 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Thu, 21 Mar 2024 21:58:40 +0700 Subject: [PATCH] chore: app now waits till MySQL is up and runnning Correction for 206d310a4be076a8d9917056d1ada16518bdf9fb commit. Part of #13 --- docker/docker-compose.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index d2ff29f..caf0a75 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -19,6 +19,15 @@ services: - '3306:3306' volumes: - ./categories.mysql.sql:/docker-entrypoint-initdb.d/categories.sql + healthcheck: + # Specifying "MYSQL_PWD" variable suppresses "Warning: Using a password on the command line interface can be insecure" + # Attention: MYSQL_PWD is deprecated as of MySQL 8.0; expect it to be removed in a future version of MySQL + # Note: double dollar sign protects variables from docker compose interpolation + test: "MYSQL_PWD=$$MYSQL_PASSWORD mysql --user=$$MYSQL_USER --silent --execute 'SELECT \"OK\" AS result'" + interval: 1s + timeout: 5s + retries: 10 + start_period: 1s express-js: @@ -32,4 +41,5 @@ services: ports: - '3010:3010' depends_on: - - mysql + mysql: + condition: service_healthy