Skip to content

Commit 9b475a4

Browse files
BenLubarGargron
authored andcommitted
Add healthcheck commands to docker-compose.yml (mastodon#9143)
This will allow Docker to be automatically check the health of services. Docker won't do anything other than showing the state in the output of "docker-compose ps" by default, but some management tools may watch for container health events. Here's what my local instance looks like right now: Name Command State Ports ------------------------------------------------------------------------------------------------------------- mastodon_db_1 docker-entrypoint.sh postgres Up (healthy) mastodon_es_1 /usr/local/bin/docker-entr ... Up (healthy) mastodon_redis_1 docker-entrypoint.sh redis ... Up (healthy) mastodon_redis_cache_1 docker-entrypoint.sh redis ... Up (healthy) mastodon_sidekiq_1 /sbin/tini -- bundle exec ... Up 3000/tcp, 4000/tcp mastodon_streaming_1 /sbin/tini -- yarn start Up (healthy) 3000/tcp, 127.0.0.1:4000->4000/tcp mastodon_web_1 /sbin/tini -- bash -c rm - ... Up (healthy) 127.0.0.1:3000->3000/tcp, 4000/tcp
1 parent d01c840 commit 9b475a4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ services:
66
image: postgres:9.6-alpine
77
networks:
88
- internal_network
9+
healthcheck:
10+
test: ["CMD", "pg_isready", "-U", "postgres"]
911
volumes:
1012
- ./postgres:/var/lib/postgresql/data
1113

@@ -14,6 +16,8 @@ services:
1416
image: redis:4.0-alpine
1517
networks:
1618
- internal_network
19+
healthcheck:
20+
test: ["CMD", "redis-cli", "ping"]
1721
volumes:
1822
- ./redis:/data
1923

@@ -24,6 +28,8 @@ services:
2428
# - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
2529
# networks:
2630
# - internal_network
31+
# healthcheck:
32+
# test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
2733
# volumes:
2834
# - ./elasticsearch:/usr/share/elasticsearch/data
2935

@@ -36,6 +42,8 @@ services:
3642
networks:
3743
- external_network
3844
- internal_network
45+
healthcheck:
46+
test: ["CMD-SHELL", "wget -q --spider --header 'x-forwarded-proto: https' --proxy off localhost:3000/api/v1/instance || exit 1"]
3947
ports:
4048
- "127.0.0.1:3000:3000"
4149
depends_on:
@@ -54,6 +62,8 @@ services:
5462
networks:
5563
- external_network
5664
- internal_network
65+
healthcheck:
66+
test: ["CMD-SHELL", "wget -q --spider --header 'x-forwarded-proto: https' --proxy off localhost:4000/api/v1/streaming/health || exit 1"]
5767
ports:
5868
- "127.0.0.1:4000:4000"
5969
depends_on:

0 commit comments

Comments
 (0)