Jashan07 commited on
Commit
db3be8b
·
1 Parent(s): f906b39

Create Dockerfile

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