kacapower commited on
Commit
83cb976
·
verified ·
1 Parent(s): 470eee0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -11
Dockerfile CHANGED
@@ -1,20 +1,24 @@
1
- # Use a lightweight Python base image
2
- FROM python:3.9-slim
3
 
4
- # Set the working directory
 
 
 
5
  WORKDIR /app
6
 
7
- # Copy dependencies first to leverage Docker caching
8
  COPY requirements.txt .
9
-
10
- # Install dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy the rest of the application files
14
- COPY . .
 
 
 
15
 
16
- # Expose the port Hugging Face Spaces expects
17
  EXPOSE 7860
18
 
19
- # Command to run the FastAPI server using Uvicorn
20
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use official Python lightweight image
2
+ FROM python:3.10-slim
3
 
4
+ # Hugging Face requires creating a specific user to run the container
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Set working directory
8
  WORKDIR /app
9
 
10
+ # Copy requirements and install
11
  COPY requirements.txt .
 
 
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
+ # Copy the entire app
15
+ COPY --chown=user:user . /app
16
+
17
+ # Switch to the non-root user
18
+ USER user
19
 
20
+ # Hugging Face Spaces route web traffic to port 7860
21
  EXPOSE 7860
22
 
23
+ # Run FastAPI using Uvicorn
24
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]