saman shrestha commited on
Commit
eb0c5b0
·
1 Parent(s): da04e19

fix: docker file

Browse files
Files changed (2) hide show
  1. Dockerfile +27 -5
  2. requirements/local.txt +2 -1
Dockerfile CHANGED
@@ -1,10 +1,32 @@
1
- FROM python:3.10-slim
2
 
3
- WORKDIR /app
 
 
4
 
5
- COPY ./requirements/prod.txt requirements.txt
6
- RUN pip install -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  COPY . .
9
 
10
- CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"]
 
 
 
 
 
 
1
+ FROM python:3.10-slim-buster
2
 
3
+ ### Set up user with permissions
4
+ # Set up a new user named "user" with user ID 1000
5
+ RUN useradd -m -u 1000 user
6
 
7
+ # Switch to the "user" user
8
+ USER user
9
+
10
+ # Set home to the user's home directory
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
+
14
+ # Set the working directory to the user's home directory
15
+ WORKDIR $HOME/app
16
+
17
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
18
+ COPY --chown=user . $HOME/app
19
+
20
+ ### Set up app-specific content
21
+ COPY requirements.txt requirements.txt
22
+ RUN pip3 install -r requirements.txt
23
+ RUN pip3 install gunicorn
24
 
25
  COPY . .
26
 
27
+ ### Update permissions for the app
28
+ USER root
29
+ RUN chmod 777 ~/app/*
30
+ USER user
31
+
32
+ CMD ["gunicorn", "-b", "0.0.0.0:7860", "flask_app:app"]
requirements/local.txt CHANGED
@@ -5,4 +5,5 @@ python-dotenv
5
  flask-session
6
  redis
7
  requests
8
- beautifulsoup4
 
 
5
  flask-session
6
  redis
7
  requests
8
+ beautifulsoup4
9
+ gunicorn