From 2c40ca491ccddf47509ba57f960d3ca97b10b384 Mon Sep 17 00:00:00 2001 From: Rob Hudson Date: Tue, 17 Dec 2024 16:45:57 -0800 Subject: [PATCH] Update docker-compose to use healthchecks --- bin/run-dev.sh | 1 - bin/run-tests.sh | 1 - docker-compose.yml | 26 ++++++++++++++++++++++++-- requirements/dev.in | 1 - requirements/dev.txt | 4 ---- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/bin/run-dev.sh b/bin/run-dev.sh index 6dac2ab4b..4d751708e 100755 --- a/bin/run-dev.sh +++ b/bin/run-dev.sh @@ -1,5 +1,4 @@ #!/bin/bash -ex -urlwait python manage.py migrate --noinput python manage.py runserver 0.0.0.0:8000 diff --git a/bin/run-tests.sh b/bin/run-tests.sh index 3e36d344f..2c6e43fe1 100755 --- a/bin/run-tests.sh +++ b/bin/run-tests.sh @@ -4,7 +4,6 @@ set -exo pipefail ruff check basket/ ruff format --check basket/ -urlwait python manage.py makemigrations | grep "No changes detected" python manage.py migrate --noinput py.test basket \ diff --git a/docker-compose.yml b/docker-compose.yml index c270d4170..7a0cde2a2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,12 +2,22 @@ services: db: image: mariadb environment: - - MYSQL_ALLOW_EMPTY_PASSWORD=yes - - MYSQL_DATABASE=basket + - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 + - MARIADB_DATABASE=basket + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 5s + timeout: 1s + retries: 5 redis: image: redis platform: linux/amd64 + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 3s + timeout: 1s + retries: 5 web: build: @@ -16,6 +26,7 @@ services: GIT_SHA: ${GIT_COMMIT:-latest} image: mozmeao/basket:${GIT_COMMIT_SHORT:-latest} platform: linux/amd64 + init: true volumes: - .:/app env_file: @@ -26,12 +37,18 @@ services: depends_on: - db - redis + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/web/8000"] + interval: 3s + timeout: 1s + retries: 10 command: ./bin/run-dev.sh worker: image: mozmeao/basket:${GIT_COMMIT_SHORT:-latest} platform: linux/amd64 + init: true restart: unless-stopped volumes: - .:/app @@ -41,6 +58,11 @@ services: depends_on: - db - redis + healthcheck: + test: ["CMD", "bash", "-c", "rq info -R default | grep -q '1 queues'"] + interval: 3s + timeout: 1s + retries: 5 command: ./bin/run-worker.sh diff --git a/requirements/dev.in b/requirements/dev.in index 60f137348..f48ed0d26 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -7,5 +7,4 @@ pytest-mock==3.14.0 pytest==8.3.4 requests-mock==1.12.1 ruff==0.8.2 -urlwait==1.0 uv==0.5.8 diff --git a/requirements/dev.txt b/requirements/dev.txt index 374431e54..b44e32c9b 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1108,10 +1108,6 @@ urllib3==2.2.3 \ # botocore # requests # sentry-sdk -urlwait==1.0 \ - --hash=sha256:a9bf2da792fa6983fa93f6360108e16615066ab0f9cfb7f53e5faee5f5dffaac \ - --hash=sha256:eae2c20001efc915166cac79c04bac0088ad5787ec64b36f27afd2f359953b2b - # via -r requirements/dev.in user-agents==2.2.0 \ --hash=sha256:a98c4dc72ecbc64812c4534108806fb0a0b3a11ec3fd1eafe807cee5b0a942e7 \ --hash=sha256:d36d25178db65308d1458c5fa4ab39c9b2619377010130329f3955e7626ead26