File size: 1,758 Bytes
f64ca43
 
 
edafd8f
f64ca43
 
 
 
 
 
 
 
 
 
 
4b164ff
f64ca43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9229664
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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