duythduong commited on
Commit
9b06bd3
·
1 Parent(s): db06678

chore: update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -12
Dockerfile CHANGED
@@ -1,17 +1,29 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.8-slim-buster
3
 
4
- # Set the working directory in the container to /app
5
- WORKDIR /app
 
6
 
7
- # Add the current directory contents into the container at /app
8
- ADD . /app
9
 
10
- # Install any needed packages specified in requirements.txt
11
- RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Make port 80 available to the world outside this container
14
- EXPOSE 7860
15
 
16
- # Run app.py when the container launches
17
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10.13-slim-bookworm
 
2
 
3
+ # Set environment variables
4
+ ENV HOME=/home/user \
5
+ PATH=/home/user/.local/bin:$PATH
6
 
7
+ # Setup new user named user with UID 1000
8
+ RUN useradd -m -u 1000 user
9
 
10
+ # Define working directory
11
+ WORKDIR $HOME/app
12
 
13
+ # Switch to user
14
+ USER user
15
 
16
+ # Copy the requirements file
17
+ COPY --chown=user:user requirements.txt $HOME/app
18
+
19
+ # Install the requirements
20
+ RUN pip install -r requirements.txt
21
+
22
+ # Copy the rest of the files
23
+ COPY --chown=user:user . $HOME/app
24
+
25
+ # Expose the port
26
+ EXPOSE 7860/tcp
27
+
28
+ # Run the application
29
+ ENTRYPOINT ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]