-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (33 loc) · 1022 Bytes
/
Dockerfile
File metadata and controls
45 lines (33 loc) · 1022 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
40
41
42
43
44
45
FROM python:3.11-slim
# Establecer directorio de trabajo
WORKDIR /app
# Instalar dependencias del sistema
RUN apt-get update && apt-get install -y \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copiar requirements primero (para cache de Docker)
COPY requirements.txt .
# Instalar dependencias de Python
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Crear usuario no-root para seguridad
RUN useradd --create-home --shell /bin/bash appuser
# Copiar código de la aplicación
COPY . .
# Crear directorio para logs
RUN mkdir -p /app/logs && \
chown -R appuser:appuser /app
# Cambiar a usuario no-root
USER appuser
# Exponer puerto
EXPOSE 8000
# Variables de entorno por defecto
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Comando de inicio
CMD ["python", "-m", "app.main"]