triflix commited on
Commit
221c179
·
verified ·
1 Parent(s): e72da52

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -0
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.10 slim image for small footprint
2
+ FROM python:3.10-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Create a non-root user (Required by Hugging Face Spaces)
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
+ COPY --chown=user ./requirements.txt requirements.txt
14
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
15
+
16
+ # Copy the application code
17
+ COPY --chown=user . .
18
+
19
+ # Create a cache directory for the model so it's writable
20
+ RUN mkdir -p /home/user/.cache/huggingface && chmod -R 777 /home/user/.cache
21
+
22
+ # Expose the Hugging Face default port
23
+ EXPOSE 7860
24
+
25
+ # Start the FastAPI server
26
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]