366degrees commited on
Commit
c629c02
·
verified ·
1 Parent(s): 8c8d036

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -28
Dockerfile CHANGED
@@ -1,28 +1,37 @@
1
- # Use lightweight Python base
2
- FROM python:3.10-slim
3
-
4
- # Set working directory
5
- WORKDIR /app
6
-
7
- # Copy files
8
- COPY . .
9
-
10
- # Install dependencies
11
- RUN pip install --no-cache-dir -r requirements.txt
12
-
13
- # Create cache directory and make it writable for non-root
14
- RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
15
-
16
- # Set environment variables for Hugging Face cache
17
- ENV HF_HOME=/app/hf_cache
18
- ENV TRANSFORMERS_CACHE=/app/hf_cache
19
-
20
- # Expose Space port
21
- EXPOSE 7860
22
-
23
- # Switch to non-root user
24
- RUN useradd -m appuser
25
- USER appuser
26
-
27
- # Run Flask directly (no Gunicorn)
28
- CMD ["python", "api_inference.py"]
 
 
 
 
 
 
 
 
 
 
1
+ # Use lightweight Python base
2
+ FROM python:3.10-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Copy files first
8
+ # These will be owned by root initially
9
+ COPY . .
10
+
11
+ # Install dependencies
12
+ RUN pip install --no-cache-dir -r requirements.txt [cite: 2]
13
+
14
+ # Create cache directory (no chmod needed yet)
15
+ RUN mkdir -p /app/hf_cache
16
+
17
+ # Set environment variables for Hugging Face cache
18
+ ENV HF_HOME=/app/hf_cache
19
+ ENV TRANSFORMERS_CACHE=/app/hf_cache
20
+
21
+ # Expose Space port
22
+ EXPOSE 7860
23
+
24
+ # --- FIX IS HERE ---
25
+ # Create non-root user
26
+ RUN useradd -m appuser
27
+
28
+ # Give the new user ownership of the entire app directory
29
+ # This includes all code files and the hf_cache
30
+ RUN chown -R appuser:appuser /app
31
+ # --- END FIX ---
32
+
33
+ # Switch to non-root user
34
+ USER appuser
35
+
36
+ # Run Flask directly (no Gunicorn)
37
+ CMD ["python", "api_inference.py"]