Skip to content

Commit

Permalink
feat: Add healthchecks for services in Docker Compose (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppawlowski authored Nov 28, 2024
1 parent b451284 commit 1b48558
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docker-compose-quick-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ services:
target: /etc/nginx/conf.d/my_proxy.conf
ports:
- "80:80"
healthcheck:
test: "curl -s -I http://localhost | head -n 1 | grep -q 503"
interval: 5s
timeout: 5s
retries: 3
start_period: 10s

postgres:
image: postgres:14
networks:
Expand All @@ -111,6 +118,13 @@ services:
target: /docker-entrypoint-initdb.d/02-setup-context-db.sh
volumes:
- db:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s

broker:
image: "iegomez/mosquitto-go-auth"
networks:
Expand All @@ -125,6 +139,7 @@ services:
configs:
- source: flowfuse_broker
target: /etc/mosquitto/mosquitto.conf

forge:
image: "flowfuse/forge-docker"
networks:
Expand All @@ -143,6 +158,12 @@ services:
- "postgres"
- "nginx"
- "broker"
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"]
interval: 5s
timeout: 5s
retries: 3
start_period: 10s

file-server:
image: "flowfuse/file-server"
Expand All @@ -156,6 +177,12 @@ services:
- fileStorage:/usr/src/flowforge-file-server/var/root
depends_on:
- "forge"
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3001/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"]
interval: 5s
timeout: 5s
retries: 3
start_period: 10s

networks:
flowforge:
Expand Down
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ services:
- "1884:1884"
environment:
- HTTPS_METHOD=${TLS_ENABLED:+redirect}
healthcheck:
test: "curl -s -I http://localhost | head -n 1 | grep -q 503"
interval: 5s
timeout: 5s
retries: 3
start_period: 10s

postgres:
image: postgres:14
Expand All @@ -448,6 +454,13 @@ services:
target: /docker-entrypoint-initdb.d/02-setup-context-db.sh
volumes:
- db:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s

broker:
image: emqx/emqx:5.8.0
networks:
Expand All @@ -471,6 +484,7 @@ services:
target: /mounted/config/api-keys
volumes:
- emqx:/opt/emqx/data

forge:
image: "flowfuse/forge-docker:2.11.0"
networks:
Expand All @@ -489,6 +503,12 @@ services:
- "postgres"
- "nginx"
- "broker"
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"]
interval: 5s
timeout: 5s
retries: 3
start_period: 10s

file-server:
image: "flowfuse/file-server:2.11.0"
Expand All @@ -502,6 +522,12 @@ services:
- fileStorage:/usr/src/flowforge-file-server/var/root
depends_on:
- "forge"
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3001/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"]
interval: 5s
timeout: 5s
retries: 3
start_period: 10s

acme:
image: nginxproxy/acme-companion:2.4.0
Expand Down

0 comments on commit 1b48558

Please sign in to comment.