Browse Source

compose: remove service_healthy condition from container dependency

Fabian Peter Hammerle 6 years ago
parent
commit
c866213945
1 changed files with 12 additions and 5 deletions
  1. 12 5
      docker-compose.yml

+ 12 - 5
docker-compose.yml

@@ -3,6 +3,9 @@
 # [...] By default, every container joins an application-wide default network,
 # and is discoverable at a hostname that’s the same as the service name. [...]
 
+# [ansible's docker_service module] works with compose versions 1 and 2.
+# https://docs.ansible.com/ansible/latest/modules/docker_service_module.html
+
 version: '2.1'
 services:
   db:
@@ -18,7 +21,7 @@ services:
     # https://docs.docker.com/engine/reference/builder/#healthcheck
     # https://github.com/docker-library/healthcheck/blob/master/postgres/docker-healthcheck
     healthcheck:
-      test: echo 'SELECT 1' | psql --username koel --dbname koel || exit 1
+      test: echo 'SELECT 1' | psql --username koel --dbname koel >/dev/null || exit 1
     restart: unless-stopped
   web:
     image: fphammerle/koel:3.7.2-wait-amd64
@@ -28,10 +31,14 @@ services:
       DB_PORT: 5432
       DB_DATABASE: koel
       DB_PASSWORD: secret
+    # TODO fix
     ports: ['8080:8080']
-    cap_drop: [all]
     # --security-opt=no-new-privileges
-    # v3 no longer supports the condition form of depends_on
-    depends_on:
-      db: {condition: service_healthy}
+    cap_drop: [all]
+    # removed condition 'service_healthy' since:
+    # - [Compose] version 3 no longer supports the condition form of depends_on.
+    #   https://docs.docker.com/compose/compose-file/#depends_on
+    # - script run-koel.sh now waits for db's tcp port to become available
+    #   as recommended by https://docs.docker.com/compose/startup-order/
+    depends_on: [db]
     restart: unless-stopped