From 67fb8c62c0beafa7788470ef00a724a824e2305f Mon Sep 17 00:00:00 2001 From: Emory Freitas Date: Mon, 11 Jan 2021 15:05:53 -0400 Subject: [PATCH] Update docker composer file version and wait for postgres #2784 This is a new approach to avoid Docker image python app initialize first, causing a failure in connection between python app and postgres. Signed-off-by: Emory Freitas --- demos/blog/docker-compose.yml | 40 ++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/demos/blog/docker-compose.yml b/demos/blog/docker-compose.yml index 95f8e84f..778800b1 100644 --- a/demos/blog/docker-compose.yml +++ b/demos/blog/docker-compose.yml @@ -1,15 +1,25 @@ -postgres: - image: postgres:10.3 - environment: - POSTGRES_USER: blog - POSTGRES_PASSWORD: blog - POSTGRES_DB: blog - ports: - - "3306" -blog: - build: . - links: - - postgres - ports: - - "8888:8888" - command: --db_host=postgres +version: "3.8" +services: + postgres: + image: postgres:10.3 + environment: + POSTGRES_USER: blog + POSTGRES_PASSWORD: blog + POSTGRES_DB: blog + ports: + - "3306" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 + blog: + build: . + links: + - postgres + depends_on: + postgres: + condition: service_healthy + ports: + - "8888:8888" + command: --db_host=postgres