From ec8523ce751891affafb376380c40facc4e89cac Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 13 Aug 2022 23:23:44 +0300 Subject: [PATCH] fix(docker): add mysql container health check This makes the prepare_backend container (which runs migrations) wait until the mysql server is actually running, not just the container. Thanks to Skyz on Discord for the implementation. --- docker-compose.production.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docker-compose.production.yml b/docker-compose.production.yml index 6ab79342..9b6a477d 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -24,6 +24,11 @@ services: volumes: - ./docker/production/data/mysql:/var/lib/mysql command: --authentication-policy=mysql_native_password + healthcheck: + test: "/usr/bin/mysql --user=root --password=\"${DOCKER_PROD_MYSQL_ROOT_PASSWORD}\" --execute \"SHOW DATABASES;\"" + interval: 5s + timeout: 300s + retries: 60 prepare_backend: build: @@ -32,7 +37,8 @@ services: DOCKER_USER_UID: ${DOCKER_USER_UID:?Missing DOCKER_USER_UID} DOCKER_USER_GID: ${DOCKER_USER_GID:?Missing DOCKER_USER_GID} depends_on: - - mysql + mysql: + condition: service_healthy volumes: - ./:/zeppelin command: |-