Spaces:
Running
Running
Commit
·
7b84b4d
1
Parent(s):
2144817
Add dockerfile
Browse files- Dockerfile +31 -0
Dockerfile
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
8 |
+
|
9 |
+
# Copy local code to the container image.
|
10 |
+
ENV APP_HOME /app
|
11 |
+
WORKDIR $APP_HOME
|
12 |
+
COPY . ./
|
13 |
+
|
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 0 main:app
|