From 13f58daf7cb5ae3f9999078ea6e1bab352059e8b Mon Sep 17 00:00:00 2001 From: Jason Cole Date: Sun, 20 Mar 2022 03:09:26 -0400 Subject: [PATCH] sorted services so that they always start in correct order In older versions of docker-compose (Say 1.23), small numbers of containers get scheduled to start up in the order in which they are listed. In this case, it was trying to start up the api first, which hangs since it cannot open connections to postgres and vault. If we put the api at the bottom of the file it will always start after postgres and vault are up. --- docker-compose.yml | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8278929..c61d07d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,26 @@ version: '3' services: + postgresql: + image: postgres:9.5-alpine + healthcheck: + test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "root" ] + timeout: 45s + interval: 10s + retries: 10 + restart: always + environment: + - POSTGRES_USER=root + - POSTGRES_PASSWORD=password + volumes: + - ./scripts/db:/docker-entrypoint-initdb.d/ + + vault: + image: vault:1.6.3 + environment: + - SKIP_SETCAP=1 + - VAULT_DEV_ROOT_TOKEN_ID=8fb95528-57c6-422e-9722-d2147bcba8ed + accountapi: image: form3tech/interview-accountapi:v1.0.0-50-ga251d4fc restart: on-failure @@ -21,22 +41,3 @@ services: - DATABASE-PASSWORD=123 ports: - 8080:8080 - postgresql: - image: postgres:9.5-alpine - healthcheck: - test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "root" ] - timeout: 45s - interval: 10s - retries: 10 - restart: always - environment: - - POSTGRES_USER=root - - POSTGRES_PASSWORD=password - volumes: - - ./scripts/db:/docker-entrypoint-initdb.d/ - - vault: - image: vault:1.6.3 - environment: - - SKIP_SETCAP=1 - - VAULT_DEV_ROOT_TOKEN_ID=8fb95528-57c6-422e-9722-d2147bcba8ed