Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +7 -7
Dockerfile
CHANGED
|
@@ -4,8 +4,7 @@ FROM python:3.10-slim
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
# This prevents permission errors when downloading models in the container.
|
| 9 |
ENV HF_HOME=/code/huggingface_cache
|
| 10 |
ENV TRANSFORMERS_CACHE=/code/huggingface_cache
|
| 11 |
|
|
@@ -13,17 +12,18 @@ ENV TRANSFORMERS_CACHE=/code/huggingface_cache
|
|
| 13 |
COPY ./requirements.txt /code/requirements.txt
|
| 14 |
|
| 15 |
# Install any needed packages specified in requirements.txt
|
| 16 |
-
# --no-cache-dir: Disables the cache, which reduces the image size
|
| 17 |
-
# --upgrade: Ensures we get the latest specified versions
|
| 18 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 19 |
|
| 20 |
-
# Copy the rest of
|
| 21 |
COPY . /code/
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
# Expose the port the app will run on. Hugging Face Spaces uses 7860 by default.
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
# Command to run the application using uvicorn
|
| 27 |
-
# --host 0.0.0.0: Makes the server accessible from outside the container
|
| 28 |
-
# --port 7860: The port to run on
|
| 29 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
+
# Set a writable cache directory for Hugging Face models
|
|
|
|
| 8 |
ENV HF_HOME=/code/huggingface_cache
|
| 9 |
ENV TRANSFORMERS_CACHE=/code/huggingface_cache
|
| 10 |
|
|
|
|
| 12 |
COPY ./requirements.txt /code/requirements.txt
|
| 13 |
|
| 14 |
# Install any needed packages specified in requirements.txt
|
|
|
|
|
|
|
| 15 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 16 |
|
| 17 |
+
# Copy the rest of the application code into the container at /code
|
| 18 |
COPY . /code/
|
| 19 |
|
| 20 |
+
# --- FIX: Change ownership of the app directory ---
|
| 21 |
+
# The container runs as a non-root user (UID 1000) who needs permission to write to the cache.
|
| 22 |
+
# This command gives that user ownership of the /code directory.
|
| 23 |
+
RUN chown -R 1000:1000 /code
|
| 24 |
+
|
| 25 |
# Expose the port the app will run on. Hugging Face Spaces uses 7860 by default.
|
| 26 |
EXPOSE 7860
|
| 27 |
|
| 28 |
# Command to run the application using uvicorn
|
|
|
|
|
|
|
| 29 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|