Gaykar commited on
Commit
1acb857
·
1 Parent(s): 34b3d71

Added dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -0
Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Save it as Dockerfile
2
+ # Use the official Python 3.9 image
3
+ FROM python:3.12-slim
4
+
5
+ # Set the working directory to /code
6
+ WORKDIR /code
7
+
8
+ # Copy the requirements.txt file into the container
9
+ COPY requirements.txt .
10
+
11
+ # Install the dependencies
12
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
+
14
+ # Set up a new user named "user" with user ID 1000
15
+ RUN useradd -m -u 1000 user
16
+
17
+ # Switch to the "user" user
18
+ USER user
19
+
20
+ # Set home to the user's home directory
21
+ ENV HOME=/home/user \
22
+ PATH=/home/user/.local/bin:$PATH
23
+
24
+ # Set the working directory to the user's home directory
25
+ WORKDIR $HOME/app
26
+
27
+ # Copy the current directory contents into the container at $HOME/app
28
+ COPY --chown=user . $HOME/app
29
+
30
+ # Expose the port FastAPI will run on
31
+ EXPOSE 7860
32
+
33
+ # Start the FastAPI app on port 7860 (HF Spaces default)
34
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]