Swapnil-101 commited on
Commit
5fc0408
·
verified ·
1 Parent(s): deedf83

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -11
Dockerfile CHANGED
@@ -1,28 +1,38 @@
1
  FROM python:3.9
2
 
3
- WORKDIR /code
4
-
5
  RUN useradd -m -u 1000 user
6
- USER user
 
7
  ENV HOME=/home/user \
8
- PATH=/home/user/.local/bin:$PATH
9
 
10
- WORKDIR $HOME/app
 
11
 
12
- COPY --chown=user . $HOME/app
 
13
 
 
14
  COPY ./requirements.txt /code/requirements.txt
15
 
 
16
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
17
 
18
- RUN mkdir -p /user/.cache && chmod 777 /user/.cache
 
19
 
20
- # Set permissions for the database file
21
- RUN touch /user/users.db && chmod 777 /user/users.db
22
 
23
  # Change ownership of mentor.txt and temp_mentor.txt
24
- RUN chown user:user /code/mentor.txt /code/temp_mentor.txt
25
 
26
- COPY --chown=user:user . /code
 
 
 
 
27
 
 
28
  CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "--timeout", "300", "main:app"]
 
1
  FROM python:3.9
2
 
3
+ # Create a user with UID 1000
 
4
  RUN useradd -m -u 1000 user
5
+
6
+ # Set the working directory and user environment variables
7
  ENV HOME=/home/user \
8
+ PATH=/home/user/.local/bin:$PATH
9
 
10
+ # Switch to the user's home directory
11
+ WORKDIR $HOME
12
 
13
+ # Copy the application files into the user's home directory
14
+ COPY --chown=user:user . $HOME
15
 
16
+ # Copy the requirements file to the /code directory
17
  COPY ./requirements.txt /code/requirements.txt
18
 
19
+ # Install the Python dependencies
20
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
21
 
22
+ # Create a directory for cache and set permissions
23
+ RUN mkdir -p $HOME/.cache && chmod 777 $HOME/.cache
24
 
25
+ # Create the database file and set permissions
26
+ RUN touch $HOME/users.db && chmod 777 $HOME/users.db
27
 
28
  # Change ownership of mentor.txt and temp_mentor.txt
29
+ RUN chown user:user $HOME/mentor.txt $HOME/temp_mentor.txt
30
 
31
+ # Switch back to the user
32
+ USER user
33
+
34
+ # Set the working directory for the application
35
+ WORKDIR $HOME/app
36
 
37
+ # Start the application using gunicorn
38
  CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "--timeout", "300", "main:app"]