aeb56 commited on
Commit
0dc6b10
·
1 Parent(s): 2352d4c

Fix UID 1000 user permission issue for Hugging Face Spaces

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -3
Dockerfile CHANGED
@@ -19,6 +19,9 @@ RUN apt-get update && apt-get install -y \
19
  # Upgrade pip
20
  RUN pip3 install --upgrade pip
21
 
 
 
 
22
  # Set working directory
23
  WORKDIR /app
24
 
@@ -31,9 +34,12 @@ RUN pip3 install --no-cache-dir -r requirements.txt
31
  # Copy application files
32
  COPY . .
33
 
34
- # Create directories for models and cache with proper permissions
35
- RUN mkdir -p /app/models /app/merged_model /app/cache /tmp/offload && \
36
- chmod -R 777 /app/models /app/merged_model /app/cache /tmp/offload
 
 
 
37
 
38
  # Expose port for Gradio
39
  EXPOSE 7860
@@ -42,6 +48,9 @@ EXPOSE 7860
42
  ENV HF_HOME=/app/cache
43
  ENV TRANSFORMERS_CACHE=/app/cache
44
 
 
 
 
45
  # Run the application
46
  CMD ["python3", "app.py"]
47
 
 
19
  # Upgrade pip
20
  RUN pip3 install --upgrade pip
21
 
22
+ # Create user with UID 1000 (Hugging Face Spaces default)
23
+ RUN useradd -m -u 1000 user
24
+
25
  # Set working directory
26
  WORKDIR /app
27
 
 
34
  # Copy application files
35
  COPY . .
36
 
37
+ # Create directories for models and cache
38
+ RUN mkdir -p /app/models /app/merged_model /app/cache /tmp/offload
39
+
40
+ # Set ownership and permissions for user
41
+ RUN chown -R user:user /app /tmp/offload && \
42
+ chmod -R 755 /app
43
 
44
  # Expose port for Gradio
45
  EXPOSE 7860
 
48
  ENV HF_HOME=/app/cache
49
  ENV TRANSFORMERS_CACHE=/app/cache
50
 
51
+ # Switch to non-root user
52
+ USER user
53
+
54
  # Run the application
55
  CMD ["python3", "app.py"]
56