From b96ccf74a02badfb7cc36518b048d9eda5fae2a2 Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Fri, 21 Jun 2024 10:56:58 +0200 Subject: [PATCH 1/4] Improve Dockerfiles This reduces layers. --- Dockerfile | 17 ++++++++++------- Dockerfile-dev | 21 +++++++++++---------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index c336b6d0..283a6eb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,19 +5,22 @@ FROM python:3.12 ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 +SHELL ["/bin/bash", "-c"] + # Set work directory WORKDIR /app # Install dependencies COPY requirements.txt /app/ -RUN apt-get update && apt-get -y upgrade -RUN apt-get install libmagic1 -y -RUN apt-get install -y gettext - -# Install dependencies -RUN pip install --upgrade pip -RUN pip install -r requirements.txt +RUN < Date: Fri, 21 Jun 2024 10:59:55 +0200 Subject: [PATCH 2/4] +gunicorn configuration --- app/gunicorn.conf.py | 12 ++++++++++++ entrypoint.sh | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 app/gunicorn.conf.py diff --git a/app/gunicorn.conf.py b/app/gunicorn.conf.py new file mode 100644 index 00000000..2aa9408e --- /dev/null +++ b/app/gunicorn.conf.py @@ -0,0 +1,12 @@ +# Send output from the web app to the error log: +capture_output = True +errorlog = "-" + +keepalive = 30 +max_requests = 1000000 +max_requests_jitter = 1000 +graceful_timeout = 5 +preload_app = True + +workers = 4 +threads = 3 diff --git a/entrypoint.sh b/entrypoint.sh index 58051188..11ebf19f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,4 +9,4 @@ python manage.py migrate --no-input python manage.py collectstatic --no-input python manage.py compilemessages -gunicorn app.wsgi:application --bind 0.0.0.0:8000 +gunicorn app.wsgi:application --bind 0.0.0.0:8000 --config gunicorn.conf.py From 1037176a18d6c5e610fad83809ff9bd929bf1d91 Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Fri, 21 Jun 2024 11:05:10 +0200 Subject: [PATCH 3/4] Enable persistent DB connections --- app/app/settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/app/settings.py b/app/app/settings.py index 88064c6b..af92a265 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -109,6 +109,8 @@ "USER": os.environ.get("DB_USER"), "PASSWORD": os.environ.get("DB_PASSWORD"), "TEST": {"NAME": "test_db"}, + "CONN_MAX_AGE": None, + "CONN_HEALTH_CHECKS": True, } } From cc64f9ed95c3615bb11ee2471102eb2d3f9ddef0 Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Fri, 21 Jun 2024 11:19:10 +0200 Subject: [PATCH 4/4] Upgrade requirements --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e89d4c52..f6d8f0c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -django==5.0.2 +django==5.0.6 django-environ django-simple-history gunicorn