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,57 +1,49 @@
# ---------------------------
# Builder stage
# ---------------------------
FROM python:3.11-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
FROM python:3.13-bookworm AS builder
# 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/*
build-essential && apt-get clean && 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)
COPY pyproject.toml ./
# Generamos wheels
RUN pip install --upgrade pip && \
pip wheel --no-cache-dir --no-deps --wheel-dir /wheels .
# Cambiamos pip por uv más moderno y rápido
RUN uv sync
# ---------------------------
# 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
# Crear usuario no-root
RUN useradd --create-home appuser
# Copiar wheels desde builder
COPY --from=builder /wheels /wheels
# Copiamos código y producto uv
# Instalar dependencias sin compilers
RUN pip install --upgrade pip && \
pip install --no-cache-dir /wheels/* && \
rm -rf /wheels
# Copiar código fuente
COPY . .
COPY --from=builder /app/.venv .venv
# Cambiar permisos
RUN chown -R appuser:appuser /app
#RUN chown -R appuser:appuser /app
USER appuser
ENV BASIC_AUTH_USERNAME=admin
ENV BASIC_AUTH_PASSWORD=admin
#USER appuser
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000