diff --git a/Dockerfile b/Dockerfile index 64ff533..9329b0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ # Pull base image FROM python:3.12.2-bookworm -# Set environment variables +# Set environment variables (we want to write bytecode as we have multiple workers) ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE 0 # Create and set work directory called `app` RUN mkdir -p /code @@ -21,7 +22,7 @@ COPY . /code/ COPY .env.production /code/.env ENV HOME=/code -RUN apt-get update && apt-get install -y nodejs npm xvfb netcat-openbsd +RUN apt-get update && apt-get install -y nodejs npm xvfb netcat-openbsd nano curl # Install playwright (via pip and install script) RUN playwright install-deps && playwright install @@ -29,5 +30,7 @@ RUN playwright install-deps && playwright install # Expose port 8000 EXPOSE 8000 +HEALTHCHECK CMD curl --fail http://localhost:8000 || exit 1 + # Use gunicorn on port 8000 -CMD ["gunicorn", "--bind", ":8000", "django_project.wsgi", "--timeout", "300"] +CMD ["gunicorn", "--bind", ":8000", "django_project.wsgi", "--workers", "4", "--worker-tmp-dir", "/dev/shm", "--timeout", "90"] diff --git a/django_project/settings.py b/django_project/settings.py index 04904f9..61748fa 100644 --- a/django_project/settings.py +++ b/django_project/settings.py @@ -2,8 +2,6 @@ import socket from pathlib import Path import environ import os -import logging -import sys env = environ.Env( DEBUG=(bool, False) @@ -29,31 +27,6 @@ RESEND_API_KEY = env('RESEND_API_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env('DEBUG') -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'verbose': { - 'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s', - }, - }, - 'handlers': { - 'console': { - 'level': 'WARN', - 'class': 'logging.StreamHandler', - 'stream': sys.stdout, - 'formatter': 'verbose' - }, - }, - 'loggers': { - '': { - 'handlers': ['console'], - 'level': 'WARN', - 'propagate': True, - }, - }, -} - # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = env('ALLOWED_HOSTS').split(',')