Skip to content

Commit

Permalink
Update docker-compose to use healthchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
robhudson committed Dec 18, 2024
1 parent 0114e4f commit 2c40ca4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
1 change: 0 additions & 1 deletion bin/run-dev.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash -ex

urlwait
python manage.py migrate --noinput
python manage.py runserver 0.0.0.0:8000
1 change: 0 additions & 1 deletion bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
26 changes: 24 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2c40ca4

Please sign in to comment.