-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
53 lines (40 loc) · 1.34 KB
/
dockerfile
File metadata and controls
53 lines (40 loc) · 1.34 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# ========================
# Stage 1 - Build
# ========================
FROM python:3.10-slim AS builder
# Variables d'environnement
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Installer dépendances système
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc build-essential libpq-dev curl && \
rm -rf /var/lib/apt/lists/*
# Créer dossier app
WORKDIR /app
# Copier requirements
COPY requirements.txt .
# Installer deps en cache
RUN pip install --upgrade pip && pip wheel --no-cache-dir --no-deps -r requirements.txt -w /wheels
# ========================
# Stage 2 - Runtime
# ========================
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
APP_HOME=/app
WORKDIR $APP_HOME
# Installer dépendances système minimales
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev curl && \
rm -rf /var/lib/apt/lists/*
# Copier deps depuis builder
COPY --from=builder /wheels /wheels
# COPY --from=builder /requirements.txt .
RUN pip install --no-cache /wheels/*
# Copier code source
COPY src/obesitrack ./src/obesitrack
COPY models ./models
# Exposer port API
EXPOSE 8000
# Lancement via gunicorn + uvicorn
CMD ["gunicorn", "src.obesitrack.main:app", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "--workers", "4", "--timeout", "120"]