Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +19 -8
Dockerfile
CHANGED
|
@@ -1,22 +1,33 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
|
|
|
| 3 |
RUN useradd -m -u 1000 user
|
| 4 |
USER user
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
|
| 8 |
-
ENV HF_HOME=/app/.cache/huggingface
|
| 9 |
-
RUN mkdir -p $TRANSFORMERS_CACHE
|
| 10 |
-
|
| 11 |
ENV PATH="/home/user/.local/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
|
|
|
| 13 |
WORKDIR /app
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
|
|
|
| 18 |
COPY --chown=user . /app
|
| 19 |
|
|
|
|
| 20 |
EXPOSE 7860
|
| 21 |
|
|
|
|
| 22 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use the official Python 3.9 image as a base image
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Create a new user with UID 1000 and switch to that user
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
USER user
|
| 7 |
|
| 8 |
+
# Set environment variables for Hugging Face cache and Python
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 10 |
+
ENV TRANSFORMERS_CACHE="/home/user/.cache/huggingface/transformers"
|
| 11 |
+
ENV HF_HOME="/home/user/.cache/huggingface"
|
| 12 |
+
ENV PYTHONUNBUFFERED=1
|
| 13 |
+
|
| 14 |
+
# Create cache directories
|
| 15 |
+
RUN mkdir -p $TRANSFORMERS_CACHE && \
|
| 16 |
+
mkdir -p $HF_HOME
|
| 17 |
|
| 18 |
+
# Set the working directory inside the container
|
| 19 |
WORKDIR /app
|
| 20 |
|
| 21 |
+
# Copy the requirements file into the container and install dependencies
|
| 22 |
+
COPY --chown=user ./requirements.txt /app/requirements.txt
|
| 23 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 24 |
+
pip install --no-cache-dir -r /app/requirements.txt
|
| 25 |
|
| 26 |
+
# Copy all project files into the container
|
| 27 |
COPY --chown=user . /app
|
| 28 |
|
| 29 |
+
# Expose the port that FastAPI will listen on (Hugging Face Spaces requires port 7860)
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
+
# Start the FastAPI app using uvicorn, listening on port 7860
|
| 33 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|