ParthSadaria commited on
Commit
33e4a89
·
verified ·
1 Parent(s): 470cd60

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python 3.10 slim image
2
+ FROM python:3.10-slim
3
+
4
+ # Create a non-root user with ID 1000 (Required by HF Spaces)
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Switch to the "user" user
8
+ USER user
9
+
10
+ # Set environment variables
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
+
14
+ # Set the working directory
15
+ WORKDIR $HOME/app
16
+
17
+ # Copy the requirements file first to leverage Docker cache
18
+ COPY --chown=user ./requirements.txt requirements.txt
19
+
20
+ # Install Python dependencies
21
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
22
+
23
+ # Copy the rest of the application code
24
+ # We use --chown=user so the app has permission to write to blogs.json
25
+ COPY --chown=user . $HOME/app
26
+
27
+ # Expose the standard HF Spaces port
28
+ EXPOSE 7860
29
+
30
+ # Command to run the app
31
+ # Ensure your python file is named 'main.py'
32
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]