#658 Add healthchecks to docker-compose.yml
Merged 3 months ago by lsedlar. Opened 3 months ago by lsedlar.
lsedlar/odcs better-docker-compose  into  master

file modified
+20 -6
@@ -12,6 +12,11 @@ 

              - 15692:15692

          volumes:

              - odcs-rabbitmq:/var/lib/rabbitmq/:z

+         healthcheck:

+           test: ["CMD-SHELL", "rabbitmq-diagnostics -q status"]

+           interval: 5s

+           timeout: 2s

+           retries: 5

  

      postgres:

          image: postgres:9
@@ -20,6 +25,11 @@ 

              POSTGRES_USER: ${POSTGRES_USER}

          volumes:

              - odcs-postgres:/var/lib/postgresql/data

+         healthcheck:

+           test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]

+           interval: 5s

+           timeout: 2s

+           retries: 5

  

      backend:

          build:
@@ -37,8 +47,10 @@ 

              - ".:/src:z"

              - odcs-composes:/mnt/odcs:z

          depends_on:

-             - rabbitmq

-             - postgres

+           rabbitmq:

+             condition: service_healthy

+           postgres:

+             condition: service_healthy

  

      frontend:

          build:
@@ -49,12 +61,13 @@ 

          entrypoint: ["/bin/sh","-c"]

          command:

              - |

-               sleep 10

                python3 /src/server/odcs/server/manage.py db upgrade

                python3 /src/server/odcs/server/manage.py run --host 0.0.0.0

          depends_on:

-             - rabbitmq

-             - postgres

+           rabbitmq:

+             condition: service_healthy

+           postgres:

+             condition: service_healthy

          ports:

              - 5000:5000

          volumes:
@@ -79,7 +92,8 @@ 

              - |

                celery-3 -b rabbitmq -A odcs.server.celery_tasks beat --loglevel=debug

          depends_on:

-             - rabbitmq

+           rabbitmq:

+             condition: service_healthy

          volumes:

              - ".:/src:z"

              - odcs-composes:/mnt/odcs:z

This allows the pods to be started once the required containers are up, without need for hacky sleep.

rebased onto 2c78aaf

3 months ago

Pull-Request has been merged by lsedlar

3 months ago
Metadata