Fariddwi commited on
Commit
13b3201
1 Parent(s): 80f4956

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -18
Dockerfile CHANGED
@@ -1,20 +1,31 @@
1
- # Base image
2
  FROM python:3.9
 
 
 
 
 
 
 
 
 
3
 
4
- # Set working directory
5
- WORKDIR /app
6
-
7
- # Copy the application files
8
- COPY app.py .
9
- COPY TextSimilarity.py .
10
- COPY requirements.txt .
11
- COPY utils.py .
12
-
13
- # Install dependencies
14
- RUN pip3 install -r requirements.txt
15
-
16
- # Expose the port
17
- EXPOSE 8000
18
-
19
- # Run the application
20
- CMD ["python3", "app.py"]
 
 
 
1
+ # Use the official Python 3.9 image
2
  FROM python:3.9
3
+
4
+ # Set the working directory to /code
5
+ WORKDIR /code
6
+
7
+ # Copy the current directory contents into the container at /code
8
+ COPY ./requirements.txt /code/requirements.txt
9
+ COPY ./app.py /code/app.py
10
+ COPY ./utils.py /code/utils.py
11
+ COPY ./TextSimilarity.py /code/TextSimilarity.py
12
 
13
+ # Install requirements.txt
14
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
15
+
16
+ # Set up a new user named "user" with user ID 1000
17
+ RUN useradd -m -u 1000 user
18
+ # Switch to the "user" user
19
+ USER user
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 setting the owner to the user
28
+ COPY --chown=user . $HOME/app
29
+
30
+ # Start the FastAPI app on port 7860, the default port expected by Spaces
31
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]