-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (32 loc) · 976 Bytes
/
Dockerfile
File metadata and controls
39 lines (32 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Use Python 3.11 slim image as base
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install system dependencies required for Python packages
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy application code
COPY . .
# Install Python dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# Production server with Gunicorn managing Uvicorn workers
# Workers = (2 * CPU cores) + 1
CMD ["gunicorn", "main:app", \
"-w", "4", \
"-k", "uvicorn.workers.UvicornWorker", \
"--bind", "0.0.0.0:80", \
"--access-logfile", "-", \
"--error-logfile", "-", \
"--max-requests", "1000", \
"--max-requests-jitter", "50", \
"--timeout", "60"]