Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -9
Dockerfile
CHANGED
|
@@ -4,18 +4,25 @@ FROM python:3.11-slim
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
RUN
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
# Copy the
|
| 14 |
-
COPY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Expose the port the app runs on
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
+
# Set the Hugging Face cache directory to a writable location
|
| 8 |
+
ENV HF_HOME=/code/.cache
|
| 9 |
|
| 10 |
+
# Create a non-root user and switch to it
|
| 11 |
+
RUN useradd --create-home --shell /bin/bash appuser
|
| 12 |
+
WORKDIR /home/appuser/app
|
| 13 |
+
USER appuser
|
| 14 |
|
| 15 |
+
# Copy only the requirements file first to leverage Docker cache
|
| 16 |
+
COPY --chown=appuser:appuser ./requirements.txt .
|
| 17 |
+
|
| 18 |
+
# Install dependencies
|
| 19 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 20 |
+
|
| 21 |
+
# Copy the rest of your app's code
|
| 22 |
+
COPY --chown=appuser:appuser . .
|
| 23 |
|
| 24 |
# Expose the port the app runs on
|
| 25 |
EXPOSE 7860
|
| 26 |
|
| 27 |
+
# Command to run the application
|
| 28 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|