File size: 1,783 Bytes
b787014
 
 
 
 
00abdcb
b787014
 
 
 
c88d0af
b787014
00abdcb
 
 
 
 
 
 
 
b787014
 
48672d3
 
b787014
48672d3
b787014
 
 
e51d074
 
 
 
 
 
 
 
 
b787014
 
de00252
deb3cb4
b787014
e51d074
 
 
9ca68b7
de00252
b787014
e51d074
 
b787014
 
 
 
616179f
de00252
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
# Usar una imagen base de Python con soporte para Debian/Ubuntu
FROM python:3.10-slim

RUN apt-get update && apt-get install -y \
    curl \
    xz-utils \
    libxrender1 \
    libxi6 \
    libxxf86vm1 \
    libfontconfig1 \
    libgl1 \
    libglib2.0-0 \
    libx11-6 \
    libxfixes3 \
    libxkbcommon0 \
    libsm6 \
    libice6 \
    libxcursor1 \
    libxrandr2 \
    libxinerama1 \
    && rm -rf /var/lib/apt/lists/*

# Descargar e Instalar Blender (versión recomendada 4.2 LTS)
RUN curl -L "https://download.blender.org/release/Blender4.2/blender-4.2.0-linux-x64.tar.xz" -o blender.tar.xz \
    && tar -xf blender.tar.xz -C /opt \
    && mv /opt/blender-4.2.0-linux-x64 /opt/blender \
    && ln -s /opt/blender/blender /usr/local/bin/blender \
    && rm blender.tar.xz

# Crear un usuario con UID 1000 (Hugging Face Spaces corre con UID 1000)
RUN useradd -m -u 1000 user

# Configurar variables de entorno del usuario
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Crear y establecer el directorio de trabajo
WORKDIR $HOME/app

# Copiar dependencias de Python e instalarlas
COPY --chown=user backend/requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt

# Copiar el código del proyecto al contenedor con propiedad del usuario
COPY --chown=user . $HOME/app

# Crear carpetas temporales y de almacenamiento y asignar la propiedad al usuario
RUN mkdir -p backend/data backend/generated/images backend/generated/models && chown -R user:user backend/data backend/generated

# Cambiar al usuario no raíz
USER user

# Indicar que usaremos el puerto de Hugging Face
EXPOSE 7860

# Comando para arrancar el servidor (usando -u para ver los logs en tiempo real)
CMD ["python", "-u", "backend/server.py"]