BraydenMoore commited on
Commit
e77a86f
·
1 Parent(s): d651008

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -9
Dockerfile CHANGED
@@ -1,7 +1,5 @@
1
-
2
  # Use the official lightweight Python image.
3
- # https://hub.docker.com/_/python
4
- FROM python:3.11-slim
5
 
6
  # Allow statements and log messages to immediately appear in the logs
7
  ENV PYTHONUNBUFFERED True
@@ -14,18 +12,17 @@ COPY . ./
14
  # Install production dependencies.
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
 
17
  RUN useradd -m -u 1000 user
18
  USER user
19
  ENV HOME=/home/user \
20
  PATH=/home/user/.local/bin:$PATH
21
 
 
22
  WORKDIR $APP_HOME
23
 
 
24
  COPY --chown=user . $HOME/app
25
 
26
- # Run the web service on container startup. Here we use the gunicorn
27
- # webserver, with one worker process and 8 threads.
28
- # For environments with multiple CPU cores, increase the number of workers
29
- # to be equal to the cores available.
30
- # Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling.
31
- CMD exec gunicorn --bind 0.0.0.0:7860 --workers 1 --threads 8 --timeout 120 main:app
 
 
1
  # Use the official lightweight Python image.
2
+ FROM python:3.11
 
3
 
4
  # Allow statements and log messages to immediately appear in the logs
5
  ENV PYTHONUNBUFFERED True
 
12
  # Install production dependencies.
13
  RUN pip install --no-cache-dir -r requirements.txt
14
 
15
+ # Create a non-root user and switch to it
16
  RUN useradd -m -u 1000 user
17
  USER user
18
  ENV HOME=/home/user \
19
  PATH=/home/user/.local/bin:$PATH
20
 
21
+ # Set work directory
22
  WORKDIR $APP_HOME
23
 
24
+ # Change ownership of app files to the new user
25
  COPY --chown=user . $HOME/app
26
 
27
+ # Run the web service on container startup.
28
+ CMD exec gunicorn --bind 0.0.0.0:7860 --workers $(nproc) --threads 8 --timeout 120 main:app