Spaces:
Running
Running
LogicalTrue commited on
Commit 路
e51d074
1
Parent(s): c88d0af
Fix HF Space port and user permissions
Browse files- Dockerfile +17 -7
- server.py +4 -1
Dockerfile
CHANGED
|
@@ -20,18 +20,28 @@ RUN curl -L "https://download.blender.org/release/Blender3.6/blender-3.6.13-linu
|
|
| 20 |
&& ln -s /opt/blender/blender /usr/local/bin/blender \
|
| 21 |
&& rm blender.tar.xz
|
| 22 |
|
| 23 |
-
# Crear
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Copiar dependencias de Python e instalarlas
|
| 27 |
-
COPY requirements.txt .
|
| 28 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 29 |
|
| 30 |
-
# Copiar el c贸digo del proyecto al contenedor
|
| 31 |
-
COPY
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
|
| 36 |
# Indicar que usaremos el puerto de Hugging Face
|
| 37 |
EXPOSE 7860
|
|
|
|
| 20 |
&& ln -s /opt/blender/blender /usr/local/bin/blender \
|
| 21 |
&& rm blender.tar.xz
|
| 22 |
|
| 23 |
+
# Crear un usuario con UID 1000 (Hugging Face Spaces corre con UID 1000)
|
| 24 |
+
RUN useradd -m -u 1000 user
|
| 25 |
+
|
| 26 |
+
# Configurar variables de entorno del usuario
|
| 27 |
+
ENV HOME=/home/user \
|
| 28 |
+
PATH=/home/user/.local/bin:$PATH
|
| 29 |
+
|
| 30 |
+
# Crear y establecer el directorio de trabajo
|
| 31 |
+
WORKDIR $HOME/app
|
| 32 |
|
| 33 |
# Copiar dependencias de Python e instalarlas
|
| 34 |
+
COPY --chown=user requirements.txt .
|
| 35 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 36 |
|
| 37 |
+
# Copiar el c贸digo del proyecto al contenedor con propiedad del usuario
|
| 38 |
+
COPY --chown=user . $HOME/app
|
| 39 |
+
|
| 40 |
+
# Crear carpetas temporales y de almacenamiento
|
| 41 |
+
RUN mkdir -p generated_images generated_models
|
| 42 |
|
| 43 |
+
# Cambiar al usuario no ra铆z
|
| 44 |
+
USER user
|
| 45 |
|
| 46 |
# Indicar que usaremos el puerto de Hugging Face
|
| 47 |
EXPOSE 7860
|
server.py
CHANGED
|
@@ -21,7 +21,10 @@ def load_dotenv():
|
|
| 21 |
line = line.strip()
|
| 22 |
if line and not line.startswith('#') and '=' in line:
|
| 23 |
key, val = line.split('=', 1)
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Initialize configuration
|
| 27 |
load_dotenv()
|
|
|
|
| 21 |
line = line.strip()
|
| 22 |
if line and not line.startswith('#') and '=' in line:
|
| 23 |
key, val = line.split('=', 1)
|
| 24 |
+
key_str = key.strip()
|
| 25 |
+
val_str = val.strip()
|
| 26 |
+
if key_str not in os.environ:
|
| 27 |
+
os.environ[key_str] = val_str
|
| 28 |
|
| 29 |
# Initialize configuration
|
| 30 |
load_dotenv()
|