iabualhaol commited on
Commit
db6d635
1 Parent(s): f9e7541

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -4
Dockerfile CHANGED
@@ -1,17 +1,33 @@
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
5
- WORKDIR /app
6
 
7
  # Copy the requirements file into the container at /app
8
- COPY requirements.txt /app/
9
 
10
  # Install any needed packages specified in requirements.txt
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
  # Copy the current directory contents into the container at /app
14
- COPY . /app/
15
 
16
  # Run the application
17
  CMD ["python", "app.py"]
 
1
  # Use an official Python runtime as a parent image
2
  FROM python:3.8-slim-buster
3
+ # Set up a new user named "user" with user ID 1000
4
+ RUN useradd -m -u 1000 user
5
+
6
+ # Switch to the "user" user
7
+ USER user
8
+
9
+ # Set home to the user's home directory
10
+ ENV HOME=/home/user \
11
+ PATH=/home/user/.local/bin:$PATH
12
+
13
+ # Set the working directory to the user's home directory
14
+ WORKDIR $HOME/app
15
+
16
+ # Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
17
+ RUN pip install --no-cache-dir --upgrade pip
18
+
19
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
20
+ COPY --chown=user . $HOME/app
21
 
 
 
22
 
23
  # Copy the requirements file into the container at /app
24
+ COPY requirements.txt .
25
 
26
  # Install any needed packages specified in requirements.txt
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
29
  # Copy the current directory contents into the container at /app
30
+ COPY . .
31
 
32
  # Run the application
33
  CMD ["python", "app.py"]