abdullahalioo commited on
Commit
9373610
·
verified ·
1 Parent(s): 19ff4f6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -6
Dockerfile CHANGED
@@ -1,10 +1,29 @@
1
- FROM python:3.10
2
 
3
- WORKDIR /app
 
4
 
5
- COPY requirements.txt .
6
- RUN pip install -r requirements.txt
7
 
8
- COPY . .
 
 
 
9
 
10
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
 
3
+ # Create a non-root user for security (required for Hugging Face Spaces Dev Mode)
4
+ RUN useradd -m -u 1000 user
5
 
6
+ # Set working directory
7
+ WORKDIR /app
8
 
9
+ # Copy requirements file and install dependencies
10
+ COPY --chown=user ./requirements.txt requirements.txt
11
+ RUN pip install --no-cache-dir --upgrade pip && \
12
+ pip install --no-cache-dir -r requirements.txt
13
 
14
+ # Copy the rest of the application code
15
+ COPY --chown=user . /app
16
+
17
+ # Switch to non-root user
18
+ USER user
19
+
20
+ # Set environment variables for Hugging Face Spaces
21
+ ENV HOME=/home/user \
22
+ PATH=/home/user/.local/bin:$PATH \
23
+ PYTHONUNBUFFERED=1
24
+
25
+ # Expose port 7860 (default for Hugging Face Spaces)
26
+ EXPOSE 7860
27
+
28
+ # Command to run the application
29
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]