2025-04-18 10:22:35 +08:00
|
|
|
FROM python:3.11-slim
|
|
|
|
|
|
|
|
WORKDIR /app
|
2025-04-25 04:38:10 +08:00
|
|
|
RUN pip install --no-cache-dir gunicorn
|
2025-04-18 10:22:35 +08:00
|
|
|
|
|
|
|
COPY requirements.txt .
|
|
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
2025-04-25 04:38:10 +08:00
|
|
|
|
2025-04-25 05:15:40 +08:00
|
|
|
|
|
|
|
# Copy the .env file first
|
2025-04-25 04:38:10 +08:00
|
|
|
# COPY .env . # ATTENTION. We shouldn't copy secrets to the image
|
2025-04-18 10:22:35 +08:00
|
|
|
|
|
|
|
# Copy the backend code
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
# Set environment variable
|
|
|
|
ENV PYTHONPATH=/app
|
|
|
|
|
2025-04-25 04:38:10 +08:00
|
|
|
|
2025-04-24 08:45:58 +08:00
|
|
|
ENV ENV_MODE="production"
|
|
|
|
|
2025-04-18 10:22:35 +08:00
|
|
|
# Expose the port the app runs on
|
|
|
|
EXPOSE 8000
|
|
|
|
|
2025-04-25 06:04:59 +08:00
|
|
|
# 24 workers
|
2025-04-25 04:38:10 +08:00
|
|
|
CMD ["gunicorn", "api:app", "--workers", "24", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000", "--timeout", "600", "--graceful-timeout", "300", "--keep-alive", "250", "--max-requests", "0", "--max-requests-jitter", "0", "--forwarded-allow-ips", "*", "--worker-connections", "5000", "--worker-tmp-dir", "/dev/shm", "--preload"]
|