Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -15
Dockerfile
CHANGED
|
@@ -1,23 +1,24 @@
|
|
| 1 |
-
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
-
# Set environment variables so Flask knows to bind on all interfaces and use port 8080
|
| 5 |
-
ENV FLASK_APP=app.py
|
| 6 |
-
ENV FLASK_RUN_HOST=0.0.0.0
|
| 7 |
-
ENV FLASK_RUN_PORT=7860
|
| 8 |
-
|
| 9 |
-
# Set the working directory in the container
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
-
# Copy
|
| 13 |
-
COPY requirements.txt requirements.txt
|
| 14 |
-
RUN pip install --upgrade
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Copy and install requirements
|
| 6 |
+
COPY requirements.txt /app/requirements.txt
|
| 7 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
| 8 |
+
|
| 9 |
+
# Set up a new non-root user
|
| 10 |
+
RUN useradd -m -u 1000 user
|
| 11 |
+
USER user
|
| 12 |
+
ENV HOME=/home/user
|
| 13 |
+
ENV PATH=/home/user/.local/bin:$PATH
|
| 14 |
|
| 15 |
+
# Create a cache directory and set environment variable
|
| 16 |
+
RUN mkdir -p /home/user/.cache && chown -R user:user /home/user/.cache
|
| 17 |
+
ENV HF_HOME=/home/user/.cache
|
| 18 |
|
| 19 |
+
# Set working directory to the user's app directory
|
| 20 |
+
WORKDIR $HOME/app
|
| 21 |
+
COPY --chown=user . $HOME/app
|
| 22 |
|
| 23 |
+
EXPOSE 8080
|
| 24 |
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]
|