-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (28 loc) · 919 Bytes
/
Copy pathDockerfile
File metadata and controls
39 lines (28 loc) · 919 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
# Build stage
FROM python:3.12-slim as builder
WORKDIR /app
# Instalar dependências de build
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copiar requirements e instalar
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
# Runtime stage
FROM python:3.12-slim
WORKDIR /app
# Copiar apenas o necessário do builder
COPY --from=builder /root/.local /root/.local
# Configurar PATH
ENV PATH=/root/.local/bin:$PATH \
PYTHONUNBUFFERED=1
# Copiar aplicação
COPY main.py .
COPY .env.example .
# Expor porta
EXPOSE 8888
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:8888/health')" || exit 1
# Comando de inicialização
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8888"]