SyamSashank commited on
Commit
09b5e1f
·
verified ·
1 Parent(s): abbca25

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -3
Dockerfile CHANGED
@@ -1,12 +1,26 @@
 
1
  FROM python:3.11-slim
2
 
 
3
  WORKDIR /app
4
 
5
- COPY requirements.txt .
 
 
 
 
 
 
 
 
 
6
  RUN pip install --no-cache-dir -r requirements.txt
7
 
8
- COPY . .
 
9
 
 
10
  EXPOSE 7860
11
 
12
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ # Use a slim Python image for a smaller footprint
2
  FROM python:3.11-slim
3
 
4
+ # Set the working directory
5
  WORKDIR /app
6
 
7
+ # Create a non-root user for Hugging Face security
8
+ RUN useradd -m -u 1000 user
9
+ USER user
10
+ ENV PATH="/home/user/.local/bin:$PATH"
11
+
12
+ # Copy requirements first to leverage Docker cache
13
+ # Use --chown=user:user to ensure the new user owns the files
14
+ COPY --chown=user:user requirements.txt .
15
+
16
+ # Install dependencies
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
+ # Copy the rest of the application code
20
+ COPY --chown=user:user . .
21
 
22
+ # Hugging Face Spaces listens on port 7860 by default
23
  EXPOSE 7860
24
 
25
+ # Start the FastAPI app using uvicorn
26
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]