WIP proxy #3

Open
garbelo wants to merge 65 commits from proxy into main
Showing only changes of commit 1a682c121e - Show all commits

View File

@@ -1,58 +1,50 @@
# --------------------------- # ---------------------------
# Builder stage # Builder stage
# --------------------------- # ---------------------------
FROM python:3.11-slim AS builder FROM python:3.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Solo herramientas necesarias para compilar dependencias # Solo herramientas necesarias para compilar dependencias
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \ build-essential && apt-get clean && rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*
ADD https://astral.sh/uv/install.sh /install.sh
RUN chmod -R 655 /install.sh && /install.sh && rm /install.sh
ENV PATH="/root/.local/bin:$PATH"
WORKDIR /app
# Copiamos solo archivos de dependencias (mejor cache) # Copiamos solo archivos de dependencias (mejor cache)
COPY pyproject.toml ./ COPY pyproject.toml ./
# Generamos wheels # Cambiamos pip por uv más moderno y rápido
RUN pip install --upgrade pip && \ RUN uv sync
pip wheel --no-cache-dir --no-deps --wheel-dir /wheels .
# --------------------------- # ---------------------------
# Runtime stage # Runtime stage
# --------------------------- # ---------------------------
FROM python:3.11-slim FROM python:3.13-slim-bookworm AS production
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1 ENV BASIC_AUTH_USERNAME=admin
ENV BASIC_AUTH_PASSWORD=admin
WORKDIR /app WORKDIR /app
# Crear usuario no-root # Crear usuario no-root
RUN useradd --create-home appuser RUN useradd --create-home appuser
# Copiar wheels desde builder # Copiamos código y producto uv
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 . . COPY . .
COPY --from=builder /app/.venv .venv
# Cambiar permisos # Cambiar permisos
RUN chown -R appuser:appuser /app #RUN chown -R appuser:appuser /app
USER appuser #USER appuser
ENV PATH="/app/.venv/bin:$PATH"
ENV BASIC_AUTH_USERNAME=admin
ENV BASIC_AUTH_PASSWORD=admin
EXPOSE 8000 EXPOSE 8000
CMD ["uvicorn", "beyond_api.main:app", "--host", "0.0.0.0", "--port", "8000"] CMD ["uvicorn", "beyond_api.main:app", "--host", "0.0.0.0", "--port", "8000"]