From fb29db7aad01ab9f3a43d7ad2466082f7191195c Mon Sep 17 00:00:00 2001 From: MaxJa4 <74194322+MaxJa4@users.noreply.github.com> Date: Sun, 30 Jan 2022 01:19:50 +0100 Subject: [PATCH] Web container waits for DB container to be ready Fixes the setup issue almost all Raspberry Pi users have and probably some others with slow or low spec systems. The web_recipes container waits for db_recipes to be healthy. db_recipes is healthy, as soon as postgres is completely ready. Note: ps_isready doesn't work here for some reason. Tested multiple times with a Raspberry Pi 4. --- docs/install/docker/plain/docker-compose.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/install/docker/plain/docker-compose.yml b/docs/install/docker/plain/docker-compose.yml index 845ee77cc..26278011a 100644 --- a/docs/install/docker/plain/docker-compose.yml +++ b/docs/install/docker/plain/docker-compose.yml @@ -7,6 +7,11 @@ services: - ./postgresql:/var/lib/postgresql/data env_file: - ./.env + healthcheck: + test: ["CMD-SHELL", "psql -U $$POSTGRES_USER -d $$POSTGRES_DB --list || exit 1"] + interval: 5s + timeout: 2s + retries: 5 web_recipes: image: vabene1111/recipes @@ -18,7 +23,8 @@ services: - nginx_config:/opt/recipes/nginx/conf.d - ./mediafiles:/opt/recipes/mediafiles depends_on: - - db_recipes + db_recipes: + condition: service_healthy nginx_recipes: image: nginx:mainline-alpine @@ -36,4 +42,4 @@ services: volumes: nginx_config: - staticfiles: \ No newline at end of file + staticfiles: