worsarise commited on
Commit
e5b9dd4
·
verified ·
1 Parent(s): ac630bc

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -0
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official lightweight Python image
2
+ FROM python:3.10-slim
3
+
4
+ # Create a non-root user (Mandatory for Hugging Face Spaces security)
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+
8
+ # Set environment variables for the user and force model caching to a writable directory
9
+ ENV HOME=/home/user \
10
+ PATH=/home/user/.local/bin:$PATH \
11
+ HF_HOME=/tmp/huggingface_cache
12
+
13
+ WORKDIR $HOME/app
14
+
15
+ # Copy requirements and install
16
+ COPY --chown=user requirements.txt .
17
+ RUN pip install --no-cache-dir -r requirements.txt
18
+
19
+ # Copy the FastAPI application code
20
+ COPY --chown=user . .
21
+
22
+ # Expose the mandatory Hugging Face port
23
+ EXPOSE 7860
24
+
25
+ # Launch the application
26
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]