Skip to content

Update docker compose syntax to Compose V2 and add healthchecks #1387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add healthchecks to docker-compose-multi.yaml
Added healthchecks and conditions for dependant containers to start only when container's healthy state is confirmed
  • Loading branch information
martkaczmarek authored Dec 11, 2024
commit 3608d8df865203a75f28f84182801b8f13a09a8f
56 changes: 50 additions & 6 deletions deploy/docker/docker-compose-multi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:

##
Expand All @@ -14,11 +13,30 @@ services:
volumes:
- ./lowcoder-stacks/data/mongodb:/data/db
restart: unless-stopped
healthcheck: # https://github.com/rodrigobdz/docker-compose-healthchecks?tab=readme-ov-file#mongo
test:
[
"CMD",
"mongosh",
"--quiet",
"127.0.0.1/test",
"--eval",
"'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'",
]
interval: 5s
timeout: 10s
retries: 10
start_period: 40s

redis:
image: redis:7-alpine
container_name: redis
restart: unless-stopped
healthcheck: # https://stackoverflow.com/a/71504657
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
interval: 1s
timeout: 3s
retries: 10


##
Expand Down Expand Up @@ -82,11 +100,20 @@ services:
LOWCODER_SUPERUSER_PASSWORD:
restart: unless-stopped
depends_on:
- mongodb
- redis
mongodb:
condition: service_healthy
restart: true
redis:
condition: service_healthy
restart: true
volumes:
- ./lowcoder-stacks:/lowcoder-stacks
- ./lowcoder-stacks/assets:/lowcoder/assets
healthcheck: #https://stackoverflow.com/questions/71101967/how-should-i-use-grep-in-docker-compose-healthcheck
test: curl -sS http://lowcoder-api-service:8080 | grep -c "Lowcoder API is up and runnig" > /dev/null
interval: 3s
timeout: 5s
retries: 10


lowcoder-node-service:
Expand All @@ -101,7 +128,14 @@ services:
LOWCODER_API_SERVICE_URL: "http://lowcoder-api-service:8080"
restart: unless-stopped
depends_on:
- lowcoder-api-service
lowcoder-api-service:
condition: service_healthy
restart: true
healthcheck: #https://stackoverflow.com/questions/71101967/how-should-i-use-grep-in-docker-compose-healthcheck
test: curl -sS http://lowcoder-node-service:6060 | grep -c "Lowcoder Node Service is up and running" > /dev/null
interval: 3s
timeout: 5s
retries: 10

##
## Start Lowcoder web frontend
Expand All @@ -120,8 +154,18 @@ services:
LOWCODER_NODE_SERVICE_URL: "http://lowcoder-node-service:6060"
restart: unless-stopped
depends_on:
- lowcoder-node-service
- lowcoder-api-service
lowcoder-node-service:
condition: service_healthy
restart: true
lowcoder-api-service:
condition: service_healthy
restart: true
volumes:
- ./lowcoder-stacks/assets:/lowcoder/assets
healthcheck:
test: curl --fail http://lowcoder-frontend:3000 || exit 1
interval: 5s
retries: 10
start_period: 10s
timeout: 10s