From 26736789f9f0e446f927fe4a7f67b1498617b7e0 Mon Sep 17 00:00:00 2001 From: Nikolay Kiryanov Date: Wed, 23 Apr 2025 20:06:18 +0300 Subject: [PATCH 1/2] Add healthcheck for web container --- {{ cookiecutter.name }}/Dockerfile | 7 ++++++- {{ cookiecutter.name }}/src/app/conf/http.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/{{ cookiecutter.name }}/Dockerfile b/{{ cookiecutter.name }}/Dockerfile index 4413ee92..bc613fef 100644 --- a/{{ cookiecutter.name }}/Dockerfile +++ b/{{ cookiecutter.name }}/Dockerfile @@ -50,7 +50,12 @@ RUN chmod +x ./manage.py RUN ./manage.py compilemessages RUN ./manage.py collectstatic --noinput -FROM base as web + +FROM base AS web +HEALTHCHECK --interval=15s --timeout=15s --start-period=15s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8000/api/v1/healthchecks/ + +SHELL ["/bin/bash", "-c"] CMD ./manage.py migrate && uwsgi --master --http :8000 --module app.wsgi --workers 2 --threads 2 --harakiri 25 --max-requests 1000 --log-x-forwarded-for diff --git a/{{ cookiecutter.name }}/src/app/conf/http.py b/{{ cookiecutter.name }}/src/app/conf/http.py index de84e241..9aec5374 100644 --- a/{{ cookiecutter.name }}/src/app/conf/http.py +++ b/{{ cookiecutter.name }}/src/app/conf/http.py @@ -1,7 +1,7 @@ from app.conf.environ import env -ALLOWED_HOSTS = ["*"] # host validation is not necessary in 2020 +ALLOWED_HOSTS = ["*"] # host validation is not necessary in 2020+ CSRF_TRUSTED_ORIGINS = [ "http://your.app.origin", ] From 31fd892b06b9af39f968f183c183f8eeff1b482b Mon Sep 17 00:00:00 2001 From: Nikolay Kiryanov Date: Sat, 26 Apr 2025 15:40:40 +0300 Subject: [PATCH 2/2] Adjust `ALLOWED_HOSTS` help comment message --- {{ cookiecutter.name }}/src/app/conf/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{ cookiecutter.name }}/src/app/conf/http.py b/{{ cookiecutter.name }}/src/app/conf/http.py index 9aec5374..9c88812f 100644 --- a/{{ cookiecutter.name }}/src/app/conf/http.py +++ b/{{ cookiecutter.name }}/src/app/conf/http.py @@ -1,7 +1,7 @@ from app.conf.environ import env -ALLOWED_HOSTS = ["*"] # host validation is not necessary in 2020+ +ALLOWED_HOSTS = ["*"] # Wildcard disables Host header validation, so pls do NOT rely on the Host header in your code with this setting enabled. CSRF_TRUSTED_ORIGINS = [ "http://your.app.origin", ]