Skip to content

Commit 9f5450d

Browse files
committed
added healthchecks to dockerfile
1 parent a183c23 commit 9f5450d

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/backend/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,6 @@ COPY . /app/
126126

127127
# The default command runs gunicorn WSGI server in messages's main module
128128
CMD ["gunicorn", "-c", "/app/gunicorn.conf.py", "messages.wsgi:application"]
129+
130+
HEALTHCHECK --interval=30s --timeout=2s --start-period=30s \
131+
CMD ["python", "-c", "import os; from urllib.request import Request, urlopen; urlopen(Request('http://localhost:8000/healthz/', headers={'Host': f'{os.getenv('DJANGO_ALLOWED_HOSTS', 'localhost').split(',')[0].strip()}', 'X-Forwarded-Proto': 'https'}), timeout=2)"]

src/frontend/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ COPY nginx/nginx.conf.template /etc/nginx/templates/default.conf.template
3232
ENV MESSAGES_FRONTEND_PORT=8080
3333
ENV MESSAGES_FRONTEND_BACKEND_SERVER=localhost:8000
3434
ENV DJANGO_ADMIN_URL=admin
35+
36+
HEALTHCHECK --interval=60s --timeout=3s --start-interval=10s \
37+
CMD curl -fsS http://localhost:${MESSAGES_FRONTEND_PORT}/health

src/frontend/nginx/nginx.conf.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ server {
6363
try_files /domain/[maildomainId]/signatures.html =404;
6464
}
6565

66+
location /health {
67+
access_log off;
68+
error_log off;
69+
return 200 'ok';
70+
}
71+
6672
location = /404.html {
6773
internal;
6874
}

0 commit comments

Comments
 (0)