tangminhanh commited on
Commit
5605ba8
·
verified ·
1 Parent(s): 7d825dd

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -13
Dockerfile CHANGED
@@ -1,22 +1,29 @@
1
  FROM python:3.10
2
 
3
- # Set the working directory in the container
4
- WORKDIR /app
5
 
6
- # Copy the requirements.txt file into the container
7
- COPY requirements.txt .
8
 
9
- # Install any dependencies specified in requirements.txt
10
- RUN pip install --no-cache-dir -r requirements.txt
11
 
12
- # Copy the rest of the working directory contents into the container
13
- COPY . .
14
 
15
- # Expose the port that the app runs on
16
- EXPOSE 8000
17
 
18
- # Define environment variable
19
- ENV PYTHONUNBUFFERED=1
 
20
 
21
- # Command to run the application
 
 
 
 
 
 
22
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
  FROM python:3.10
2
 
3
+ # Set the working directory to /code
4
+ WORKDIR /code
5
 
6
+ # Copy the requirements file into the container
7
+ COPY ./requirements.txt /code/requirements.txt
8
 
9
+ # Install dependencies from the requirements file
10
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
11
 
12
+ # Set up a new user named "user" with user ID 1000
13
+ RUN useradd -m -u 1000 user
14
 
15
+ # Switch to the "user" user
16
+ USER user
17
 
18
+ # Set environment variables for the user's home directory and path
19
+ ENV HOME=/home/user \
20
+ PATH=/home/user/.local/bin:$PATH
21
 
22
+ # Set the working directory to the user's home directory
23
+ WORKDIR $HOME/app
24
+
25
+ # Copy the current directory contents into the container at $HOME/app and set ownership to the user
26
+ COPY --chown=user . $HOME/app
27
+
28
+ # Start the FastAPI app on port 8000
29
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]