agentsay commited on
Commit
2e0d130
·
verified ·
1 Parent(s): dc0efb7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -16
Dockerfile CHANGED
@@ -1,16 +1,26 @@
1
- # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
3
-
4
- FROM python:3.9
5
-
6
- RUN useradd -m -u 1000 user
7
- USER user
8
- ENV PATH="/home/user/.local/bin:$PATH"
9
-
10
- WORKDIR /app
11
-
12
- COPY --chown=user ./requirements.txt requirements.txt
13
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
-
15
- COPY --chown=user . /app
16
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Python 3.9 slim image as base (smaller footprint than full Python image)
2
+ FROM python:3.9-slim
3
+
4
+ # Create non-root user as recommended by Hugging Face Spaces
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+ ENV PATH="/home/user/.local/bin:$PATH"
8
+
9
+ # Set working directory
10
+ WORKDIR /home/user/app
11
+
12
+ # Copy requirements first (optimization for caching)
13
+ COPY --chown=user:user ./requirements.txt requirements.txt
14
+
15
+ # Install dependencies
16
+ RUN pip install --no-cache-dir --upgrade pip && \
17
+ pip install --no-cache-dir -r requirements.txt
18
+
19
+ # Copy application code
20
+ COPY --chown=user:user . .
21
+
22
+ # Expose port (7860 is the default for Hugging Face Spaces)
23
+ EXPOSE 7860
24
+
25
+ # Run the application
26
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]