GPTfree api commited on
Commit
a50c7f7
·
verified ·
1 Parent(s): d9f0914

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -2
Dockerfile CHANGED
@@ -4,18 +4,27 @@ FROM python:3.9-slim
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 && rm -rf /var/lib/apt/lists/*
9
 
10
  # Clone the repository
11
  RUN git clone https://github.com/Lightmoll/MigaduTrashmail.git .
12
 
 
 
 
 
 
 
13
  # Create a virtual environment
14
  RUN python3 -m venv venv
15
 
16
  # Activate virtual environment and install requirements
17
  RUN . venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt
18
 
 
 
 
19
  # Copy default_config.py to config.py
20
  RUN cp default_config.py config.py
21
 
@@ -23,4 +32,4 @@ RUN cp default_config.py config.py
23
  EXPOSE 8000
24
 
25
  # Set the command to run the application
26
- CMD ["/bin/bash", "-c", ". venv/bin/activate && python3 server.py"]
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
+ # Install git and required tools
8
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
9
 
10
  # Clone the repository
11
  RUN git clone https://github.com/Lightmoll/MigaduTrashmail.git .
12
 
13
+ # Create a non-root user and group
14
+ RUN groupadd -r appuser && useradd -r -g appuser appuser
15
+
16
+ # Change ownership of the working directory
17
+ RUN chown -R appuser:appuser /app
18
+
19
  # Create a virtual environment
20
  RUN python3 -m venv venv
21
 
22
  # Activate virtual environment and install requirements
23
  RUN . venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt
24
 
25
+ # Switch to the non-root user
26
+ USER appuser
27
+
28
  # Copy default_config.py to config.py
29
  RUN cp default_config.py config.py
30
 
 
32
  EXPOSE 8000
33
 
34
  # Set the command to run the application
35
+ CMD ["/bin/bash", "-c", ". venv/bin/activate && python3 server.py"]