Spaces:
Sleeping
Sleeping
CarlosMalaga
commited on
Commit
•
0877a86
1
Parent(s):
2cfebfc
Update Dockerfile
Browse files- Dockerfile +8 -6
Dockerfile
CHANGED
@@ -1,23 +1,25 @@
|
|
|
|
1 |
FROM tiangolo/uvicorn-gunicorn:python3.10-slim
|
2 |
|
|
|
3 |
RUN adduser --disabled-password --gecos '' retriever-user \
|
4 |
&& apt-get update \
|
5 |
&& apt-get install -y --no-install-recommends \
|
6 |
curl wget python3.10 python3-distutils python3-pip \
|
7 |
&& rm -rf /var/lib/apt/lists/*
|
8 |
|
|
|
9 |
USER retriever-user
|
10 |
-
ENV PATH=${PATH}:/home/retriever-user/.local/bin
|
11 |
|
12 |
-
# Set the working directory
|
13 |
COPY --chown=retriever-user:retriever-user . /home/retriever-user/retriever
|
14 |
WORKDIR /home/retriever-user/retriever
|
15 |
|
16 |
-
#
|
17 |
-
# ENV PATH="/root/conda/bin:${PATH}"
|
18 |
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
|
|
|
20 |
EXPOSE 8000
|
21 |
|
22 |
-
# Run
|
23 |
-
CMD ["
|
|
|
1 |
+
# Use a base image optimized for Python with Uvicorn and Gunicorn installed
|
2 |
FROM tiangolo/uvicorn-gunicorn:python3.10-slim
|
3 |
|
4 |
+
# Add a non-root user and install necessary packages
|
5 |
RUN adduser --disabled-password --gecos '' retriever-user \
|
6 |
&& apt-get update \
|
7 |
&& apt-get install -y --no-install-recommends \
|
8 |
curl wget python3.10 python3-distutils python3-pip \
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
+
# Switch to non-root user for security
|
12 |
USER retriever-user
|
|
|
13 |
|
14 |
+
# Set the working directory and copy application files
|
15 |
COPY --chown=retriever-user:retriever-user . /home/retriever-user/retriever
|
16 |
WORKDIR /home/retriever-user/retriever
|
17 |
|
18 |
+
# Install Python dependencies
|
|
|
19 |
RUN pip install --no-cache-dir -r requirements.txt
|
20 |
|
21 |
+
# Expose the port Flask will run on
|
22 |
EXPOSE 8000
|
23 |
|
24 |
+
# Run Flask command to serve the application
|
25 |
+
CMD ["gunicorn", "-w 4", "-b :8000", "app:app"]
|