Files
BeyondCXAnalytics-Demo/backend/Dockerfile
garbelo c633124454
All checks were successful
Workflow de prueba / Build and push images (push) Successful in 1m36s
Reduccion 1
2026-02-15 15:08:56 +00:00

58 lines
1.2 KiB
Docker

# ---------------------------
# Builder stage
# ---------------------------
FROM python:3.11-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Solo herramientas necesarias para compilar dependencias
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copiamos solo archivos de dependencias (mejor cache)
COPY pyproject.toml ./
# Generamos wheels
RUN pip install --upgrade pip && \
pip wheel --no-cache-dir --no-deps --wheel-dir /wheels .
# ---------------------------
# Runtime stage
# ---------------------------
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Crear usuario no-root
RUN useradd --create-home appuser
# Copiar wheels desde builder
COPY --from=builder /wheels /wheels
# Instalar dependencias sin compilers
RUN pip install --upgrade pip && \
pip install --no-cache-dir /wheels/* && \
rm -rf /wheels
# Copiar código fuente
COPY . .
# Cambiar permisos
RUN chown -R appuser:appuser /app
USER appuser
ENV BASIC_AUTH_USERNAME=admin
ENV BASIC_AUTH_PASSWORD=admin
EXPOSE 8000
CMD ["uvicorn", "beyond_api.main:app", "--host", "0.0.0.0", "--port", "8000"]