sidd-harth011 commited on
Commit
129ad8f
·
1 Parent(s): 67e4602
Files changed (1) hide show
  1. Dockerfile +11 -3
Dockerfile CHANGED
@@ -4,18 +4,26 @@ FROM python:3.11-slim
4
  # Set working directory
5
  WORKDIR /app
6
 
 
 
 
 
 
 
 
 
7
  # Set HF cache inside container
8
  ENV HF_HUB_CACHE=/tmp/hf_cache
9
 
10
  # Copy requirements and install
11
- COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
  # Copy the rest of the app
15
- COPY . .
16
 
17
  # Expose the port HF Spaces uses
18
  EXPOSE 7860
19
 
20
  # Run the Flask app
21
- CMD ["python", "app.py"]
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Create a non-root user and set permissions
8
+ RUN useradd -m -u 1000 user && \
9
+ mkdir -p /tmp/hf_cache && \
10
+ chown -R user:user /tmp/hf_cache /app
11
+
12
+ # Switch to non-root user
13
+ USER user
14
+
15
  # Set HF cache inside container
16
  ENV HF_HUB_CACHE=/tmp/hf_cache
17
 
18
  # Copy requirements and install
19
+ COPY --chown=user:user requirements.txt .
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
  # Copy the rest of the app
23
+ COPY --chown=user:user . .
24
 
25
  # Expose the port HF Spaces uses
26
  EXPOSE 7860
27
 
28
  # Run the Flask app
29
+ CMD ["python", "app.py"]