File size: 855 Bytes
cc19654
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ---------- base image ----------
FROM python:3.11-slim

# ---------- runtime options ----------
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    LOG_LEVEL=INFO \
    WORKERS=4         

# ---------- install system deps ----------
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential curl && \
    rm -rf /var/lib/apt/lists/*

# ---------- install Python deps ----------
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# ---------- copy source ----------
COPY . .

# ---------- network ----------
EXPOSE 8000

# ---------- healthcheck ----------
HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD \
  curl -sf http://localhost:8000/health || exit 1

# ---------- start ----------
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 8000 --workers $WORKERS"]