|
|
@@ -4,9 +4,6 @@ ENV DEBIAN_FRONTEND=noninteractive
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
ENV GRADIO_SERVER_NAME=0.0.0.0
|
|
|
ENV GRADIO_SERVER_PORT=7860
|
|
|
-ENV HF_HOME=/tmp/hf_cache
|
|
|
-ENV TRANSFORMERS_CACHE=/tmp/hf_cache
|
|
|
-ENV TORCH_HOME=/tmp/torch_cache
|
|
|
|
|
|
# System dependencies
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
|
@@ -33,6 +30,9 @@ RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://
|
|
|
# Install flash-attention for faster training
|
|
|
RUN pip install --no-cache-dir flash-attn --no-build-isolation 2>/dev/null || echo "Flash attention build failed, continuing without it"
|
|
|
|
|
|
+# Create non-root user FIRST
|
|
|
+RUN useradd -m -u 1000 user
|
|
|
+
|
|
|
# Create app directory
|
|
|
WORKDIR /app
|
|
|
|
|
|
@@ -43,20 +43,19 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
|
# Copy app files
|
|
|
COPY . .
|
|
|
|
|
|
-# Create non-root user for HF Spaces
|
|
|
-RUN useradd -m -u 1000 user
|
|
|
-
|
|
|
-# Create cache directories and make them owned by the non-root user
|
|
|
-RUN mkdir -p /tmp/hf_cache /tmp/torch_cache /tmp/qwen3-uncensored-lora /tmp/merged_model \
|
|
|
- && chown -R user:user /tmp/hf_cache /tmp/torch_cache /tmp/qwen3-uncensored-lora /tmp/merged_model \
|
|
|
- && chmod -R 777 /tmp/hf_cache /tmp/torch_cache /tmp/qwen3-uncensored-lora /tmp/merged_model \
|
|
|
- && chown -R user:user /app
|
|
|
-
|
|
|
-USER user
|
|
|
+# Create ALL directories under user home (NOT /tmp)
|
|
|
+RUN mkdir -p /home/user/hf_cache /home/user/torch_cache /home/user/output /home/user/merged \
|
|
|
+ && chown -R user:user /home/user /app
|
|
|
|
|
|
+# Set cache env vars to user home
|
|
|
ENV HOME=/home/user
|
|
|
+ENV HF_HOME=/home/user/hf_cache
|
|
|
+ENV TRANSFORMERS_CACHE=/home/user/hf_cache
|
|
|
+ENV TORCH_HOME=/home/user/torch_cache
|
|
|
ENV PATH="/home/user/.local/bin:$PATH"
|
|
|
|
|
|
+USER user
|
|
|
+
|
|
|
EXPOSE 7860
|
|
|
|
|
|
CMD ["python", "app.py"]
|