2026-04-09 13:56:02 +00:00
|
|
|
FROM python:3.11-slim
|
|
|
|
|
|
|
|
|
|
# Set environment variables
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
|
|
|
# Set work directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Install system dependencies
|
|
|
|
|
RUN apt-get update && apt-get install \
|
|
|
|
|
gcc \
|
|
|
|
|
postgresql-client \
|
|
|
|
|
-y --no-install-recommends && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2026-04-14 02:13:32 +00:00
|
|
|
# Install Python dependencies (use Tsinghua mirror for faster download in China)
|
2026-04-09 13:56:02 +00:00
|
|
|
COPY requirements.txt .
|
2026-04-14 02:13:32 +00:00
|
|
|
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
|
2026-04-09 13:56:02 +00:00
|
|
|
|
|
|
|
|
# Copy project
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Collect static files
|
|
|
|
|
RUN python manage.py collectstatic --noinput --settings=config.settings.prod
|
|
|
|
|
|
|
|
|
|
# Expose port
|
|
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
|
|
# Run gunicorn
|
|
|
|
|
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3"]
|