27 lines
928 B
Text
27 lines
928 B
Text
# 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
|
|
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir --upgrade pip \
|
|
&& pip install --no-cache-dir -r requirements.txt gunicorn
|
|
|
|
COPY . .
|
|
|
|
# collectstatic only needs Django settings to import cleanly, not a real
|
|
# secret; the actual SECRET_KEY is injected at container runtime via
|
|
# --env-file and overrides this.
|
|
RUN SECRET_KEY=build-time-placeholder 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"]
|