Skip to content

Commit 03c8406

Browse files
chore: add health checks to Docker Compose file (#3240)
Co-authored-by: David Regla <[email protected]>
1 parent a2eeaf4 commit 03c8406

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

docker-compose.yml

+26-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# See https://docs.flagsmith.com/deployment/docker for more information on running Flagsmith in Docker
2-
# This will docker-compose file will run the entire Flagsmith Platform in Docker
2+
# This Docker Compose file will run the entire Flagsmith Platform
33

44
version: '3'
55

@@ -15,6 +15,12 @@ services:
1515
container_name: flagsmith_postgres
1616
volumes:
1717
- pgdata:/var/lib/postgresql/data
18+
healthcheck:
19+
test: ['CMD-SHELL', 'pg_isready -d flagsmith -U postgres']
20+
interval: 2s
21+
timeout: 2s
22+
retries: 20
23+
start_period: 20s
1824

1925
flagsmith:
2026
image: flagsmith/flagsmith:latest
@@ -26,34 +32,38 @@ services:
2632
DATABASE_URL: postgresql://postgres:password@postgres:5432/flagsmith
2733
USE_POSTGRES_FOR_ANALYTICS: 'true' # Store API and Flag Analytics data in Postgres
2834

29-
ENV: prod # set to "prod" in production.
35+
ENV: prod # set to 'prod' in production.
3036
DJANGO_ALLOWED_HOSTS: '*' # Change this in production
3137
ALLOW_ADMIN_INITIATION_VIA_CLI: 'true' # Change this in production
32-
FLAGSMITH_DOMAIN: 'localhost:8000' # Change this in production
33-
DJANGO_SECRET_KEY: 'secret' # Change this in production
34-
# PREVENT_SIGNUP: "true" # Uncomment to prevent additional signups
35-
# ENABLE_ADMIN_ACCESS_USER_PASS: "true" # set to "true" to enable access to the /admin/ Django backend via your username and password
36-
# ALLOW_REGISTRATION_WITHOUT_INVITE: "true"
38+
FLAGSMITH_DOMAIN: localhost:8000 # Change this in production
39+
DJANGO_SECRET_KEY: secret # Change this in production
40+
# PREVENT_SIGNUP: 'true' # Uncomment to prevent additional signups
41+
# ENABLE_ADMIN_ACCESS_USER_PASS: 'true' # Uncomment to enable access to the /admin/ Django backend via your username and password
42+
# ALLOW_REGISTRATION_WITHOUT_INVITE: 'true'
3743

3844
# Enable Task Processor
3945
TASK_RUN_METHOD: TASK_PROCESSOR # other options are: SYNCHRONOUSLY, SEPARATE_THREAD (default)
46+
4047
# For more info on configuring E-Mails - https://docs.flagsmith.com/deployment/locally-api#environment-variables
41-
#
4248
# Example SMTP:
4349
# EMAIL_BACKEND: django.core.mail.backends.smtp.EmailBackend
4450
# EMAIL_HOST: mail.example.com
4551
# SENDER_EMAIL: [email protected]
4652
# EMAIL_HOST_USER: [email protected]
4753
# EMAIL_HOST_PASSWORD: smtp_account_password
4854
# EMAIL_PORT: 587 # optional
49-
# EMAIL_USE_TLS: "true" # optional
50-
55+
# EMAIL_USE_TLS: 'true' # optional
5156
ports:
52-
- '8000:8000'
57+
- 8000:8000
58+
healthcheck:
59+
test: ['CMD-SHELL', 'python /app/scripts/healthcheck.py']
60+
interval: 2s
61+
timeout: 2s
62+
retries: 20
63+
start_period: 20s
5364
depends_on:
54-
- postgres
55-
links:
56-
- postgres
65+
postgres:
66+
condition: service_healthy
5767

5868
# The flagsmith_processor service is only needed if TASK_RUN_METHOD set to TASK_PROCESSOR
5969
# in the application environment
@@ -63,8 +73,6 @@ services:
6373
DATABASE_URL: postgresql://postgres:password@postgres:5432/flagsmith
6474
USE_POSTGRES_FOR_ANALYTICS: 'true'
6575
depends_on:
66-
- flagsmith
67-
- postgres
68-
links:
69-
- postgres
76+
flagsmith:
77+
condition: service_healthy
7078
command: run-task-processor

0 commit comments

Comments
 (0)