pvanand commited on
Commit
d45e294
·
verified ·
1 Parent(s): 0d8f4bb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -6
Dockerfile CHANGED
@@ -1,20 +1,39 @@
1
- # Use an official Python runtime as the base image
2
  FROM python:3.9-slim
3
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
- # Install git
8
  RUN apt-get update && apt-get install -y git
9
 
10
  # Clone the repository
11
  RUN git clone https://github.com/pvanand07/flask-web-server-with-auth.git .
12
 
13
- # Install the required packages
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Expose the port the app runs on
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  EXPOSE 5000
18
 
19
- # Run the application
20
- CMD ["python", "main.py"]
 
 
 
 
1
+ # Use the official Python base image
2
  FROM python:3.9-slim
3
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
+ # Install git and other necessary packages
8
  RUN apt-get update && apt-get install -y git
9
 
10
  # Clone the repository
11
  RUN git clone https://github.com/pvanand07/flask-web-server-with-auth.git .
12
 
13
+ # Install the Python dependencies
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Set up a new user named "user" with user ID 1000
17
+ RUN useradd -m -u 1000 user
18
+
19
+ # Switch to the "user" user
20
+ USER user
21
+
22
+ # Set home to the user's home directory
23
+ ENV HOME=/home/user \
24
+ PATH=/home/user/.local/bin:$PATH
25
+
26
+ # Set the working directory to the user's home directory
27
+ WORKDIR $HOME/app
28
+
29
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
30
+ COPY --chown=user . $HOME/app
31
+
32
+ # Expose the port on which the Flask application will run
33
  EXPOSE 5000
34
 
35
+ # Set the environment variable for Flask
36
+ ENV FLASK_APP=main.py
37
+
38
+ # Run the Flask application
39
+ CMD ["flask", "run", "--host=0.0.0.0"]