Skip to content

Commit

Permalink
🔨(docker) add docker container healthcheck
Browse files Browse the repository at this point in the history
Add docker compose healthcheck for containers: elasticsearch, app,
redis and redis sentinel.

#2455
  • Loading branch information
igobranco committed Jul 24, 2024
1 parent 92c9bf2 commit 4f6e179
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ services:
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"

healthcheck:
test: ["CMD", "echo", "''", ">", "/dev/tcp/127.0.0.1/9200", "||", "exit", "1"]
interval: 1s
timeout: 2s
retries: 300
app:
build:
context: .
Expand All @@ -29,9 +33,15 @@ services:
depends_on:
elasticsearch:
condition: service_started
redis-sentinel:
condition: service_started
stdin_open: true
tty: true

healthcheck:
test: ["CMD", "echo", "''", ">", "/dev/tcp/127.0.0.1/8000", "||", "exit", "1"]
interval: 1s
timeout: 2s
retries: 3600
nginx:
image: nginx
ports:
Expand Down Expand Up @@ -84,12 +94,22 @@ services:
- redis-replica2
environment:
- REDIS_MASTER_HOST=redis-primary
healthcheck:
test: ["CMD-SHELL", "redis-cli -p 26379 ping | grep PONG"]
interval: 1s
timeout: 2s
retries: 300

redis-primary:
image: docker.io/bitnami/redis:6.0-debian-10
environment:
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_REPLICATION_MODE=master
healthcheck:
test: ["CMD-SHELL", "redis-cli -p 6379 ping | grep PONG"]
interval: 1s
timeout: 2s
retries: 300

redis-replica1:
image: docker.io/bitnami/redis:6.0-debian-10
Expand All @@ -99,6 +119,11 @@ services:
- REDIS_MASTER_HOST=redis-primary
depends_on:
- redis-primary
healthcheck:
test: ["CMD-SHELL", "redis-cli -p 6379 ping | grep PONG"]
interval: 1s
timeout: 2s
retries: 300

redis-replica2:
image: docker.io/bitnami/redis:6.0-debian-10
Expand All @@ -108,9 +133,11 @@ services:
- REDIS_MASTER_HOST=redis-primary
depends_on:
- redis-primary

dockerize:
image: jwilder/dockerize
healthcheck:
test: ["CMD-SHELL", "redis-cli -p 6379 ping | grep PONG"]
interval: 1s
timeout: 2s
retries: 300

networks:
lms_outside:
Expand Down

0 comments on commit 4f6e179

Please sign in to comment.