ARG PORT=7860 ARG PROXY_CONTENT=TRUE ARG SOCKS5 ARG API_URL="https://docs4you-restest.hf.space" FROM python:3.13 AS builder RUN apt-get update && apt-get install -y git curl unzip util-linux procps gnupg ca-certificates # Crear usuario y grupo con UID/GID 1000 RUN groupadd -g 1000 appuser && useradd -u 1000 -g 1000 -m appuser # Clonar el repositorio como usuario appuser USER appuser WORKDIR /app RUN git clone https://github.com/MarkMCFC/broke . --depth 1 # Crear entorno virtual RUN python -m venv /home/appuser/venv ENV PATH="/home/appuser/venv/bin:$PATH" # Instalar dependencias RUN pip install --upgrade pip && pip install -r requirements.txt ARG PORT API_URL PROXY_CONTENT SOCKS5 # Crear directorio para archivos estáticos y ejecutar reflex export RUN mkdir -p /tmp/static \ && API_URL=${API_URL:-http://localhost:$PORT} reflex export --loglevel debug --frontend-only --no-zip \ && mv .web/_static/* /tmp/static/ \ && rm -rf .web FROM python:3.13-slim RUN apt-get update -y && apt-get install -y caddy redis-server && rm -rf /var/lib/apt/lists/* ARG PORT API_URL ENV PATH="/home/appuser/venv/bin:$PATH" \ PORT=$PORT \ API_URL=${API_URL:-http://localhost:$PORT} \ REDIS_URL=redis://localhost \ PYTHONUNBUFFERED=1 \ PROXY_CONTENT=${PROXY_CONTENT:-TRUE} \ SOCKS5=${SOCKS5:-""} # Usar el mismo UID/GID que en la etapa de construcción USER 1000:1000 WORKDIR /app # Copiar desde el stage builder COPY --from=builder --chown=1000:1000 /home/appuser/venv /home/appuser/venv COPY --from=builder --chown=1000:1000 /app /app COPY --from=builder --chown=1000:1000 /tmp/static /srv # Iniciar servicios CMD caddy start && \ redis-server --daemonize yes && \ exec reflex run --env prod --backend-only