# Production image for the Django backend. # Runs migrations then serves the app with gunicorn on port 8000. # Static files are collected at build time into /app/staticfiles and # served by the backend itself behind the host nginx reverse proxy. FROM python:3.11-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ DJANGO_SETTINGS_MODULE=backend.settings WORKDIR /app RUN apt-get update \ && apt-get install -y --no-install-recommends gcc \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt gunicorn COPY . . RUN python manage.py collectstatic --noinput EXPOSE 8000 CMD ["sh", "-c", "python manage.py migrate --noinput && exec gunicorn backend.wsgi:application --bind 0.0.0.0:8000 --workers 3"]