pvanand commited on
Commit
b2cb998
·
verified ·
1 Parent(s): 867f1cf

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -9
Dockerfile CHANGED
@@ -1,23 +1,32 @@
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
  # Expose the port on which the Flask application will run
17
  EXPOSE 5000
18
 
19
  # Set the environment variable for Flask
20
- ENV FLASK_APP=main.py
21
 
22
  # Run the Flask application
23
- CMD ["flask","--app","main", "run", "--host=0.0.0.0"]
 
1
  # Use the official Python base image
2
+ FROM python:3.9
3
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
+ # Copy the requirements.txt file and install the Python dependencies
8
+ COPY requirements.txt .
9
+ RUN pip install --no-cache-dir -r requirements.txt
10
 
11
+ # Set up a new user named "user" with user ID 1000
12
+ RUN useradd -m -u 1000 user
13
+ # Switch to the "user" user
14
+ USER user
15
+ # Set home to the user's home directory
16
+ ENV HOME=/home/user \
17
+ PATH=/home/user/.local/bin:$PATH
18
 
19
+ # Set the working directory to the user's home directory
20
+ WORKDIR $HOME/app
21
+
22
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
23
+ COPY --chown=user . $HOME/app
24
 
25
  # Expose the port on which the Flask application will run
26
  EXPOSE 5000
27
 
28
  # Set the environment variable for Flask
29
+ ENV FLASK_APP=api_server.py
30
 
31
  # Run the Flask application
32
+ CMD ["flask", "run", "--host=0.0.0.0"]