Spaces:
Runtime error
Runtime error
Fix: huggingface cache permissions
Browse files- Dockerfile +6 -8
Dockerfile
CHANGED
|
@@ -4,6 +4,10 @@ FROM python:3.11-slim-buster
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# Install ffmpeg, which is required by pydub.
|
| 8 |
# We also clean up the apt cache to reduce image size.
|
| 9 |
RUN apt-get update && \
|
|
@@ -11,30 +15,24 @@ RUN apt-get update && \
|
|
| 11 |
rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
# Copy the requirements file into the working directory first
|
| 14 |
-
# This allows Docker to cache this layer if requirements.txt doesn't change
|
| 15 |
COPY requirements.txt .
|
| 16 |
|
| 17 |
# Install all Python dependencies from requirements.txt
|
| 18 |
-
# --no-cache-dir reduces the size of the installed packages
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
# --- Create and set appropriate permissions for all directories used by the application ---
|
| 22 |
-
#
|
| 23 |
-
# by the user running the app inside the container (typically root by default in slim-buster).
|
| 24 |
-
# 'chmod 777' grants full read/write/execute permissions to all, ensuring no permission issues.
|
| 25 |
RUN mkdir -p uploads && chmod 777 uploads
|
| 26 |
RUN mkdir -p converted_audio_temp && chmod 777 converted_audio_temp
|
| 27 |
RUN mkdir -p transcriptions && chmod 777 transcriptions
|
|
|
|
| 28 |
# -----------------------------------------------------------------------------------------
|
| 29 |
|
| 30 |
# Copy the rest of your application code into the working directory
|
| 31 |
-
# Ensure your main.py, and any other Python files/folders, are in the same directory
|
| 32 |
-
# as your Dockerfile when you build.
|
| 33 |
COPY . .
|
| 34 |
|
| 35 |
# Expose the port that your FastAPI application will run on
|
| 36 |
EXPOSE 8000
|
| 37 |
|
| 38 |
# Command to run your FastAPI application using Uvicorn
|
| 39 |
-
# The application will listen on all network interfaces (0.0.0.0) on port 8000
|
| 40 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# --- Set Hugging Face cache directory to a writable location within the WORKDIR ---
|
| 8 |
+
ENV HF_HOME /app/.cache/huggingface
|
| 9 |
+
# ----------------------------------------------------------------------------------
|
| 10 |
+
|
| 11 |
# Install ffmpeg, which is required by pydub.
|
| 12 |
# We also clean up the apt cache to reduce image size.
|
| 13 |
RUN apt-get update && \
|
|
|
|
| 15 |
rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
# Copy the requirements file into the working directory first
|
|
|
|
| 18 |
COPY requirements.txt .
|
| 19 |
|
| 20 |
# Install all Python dependencies from requirements.txt
|
|
|
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
# --- Create and set appropriate permissions for all directories used by the application ---
|
| 24 |
+
# This includes the new HF_HOME path and your app-specific directories.
|
|
|
|
|
|
|
| 25 |
RUN mkdir -p uploads && chmod 777 uploads
|
| 26 |
RUN mkdir -p converted_audio_temp && chmod 777 converted_audio_temp
|
| 27 |
RUN mkdir -p transcriptions && chmod 777 transcriptions
|
| 28 |
+
RUN mkdir -p ${HF_HOME} && chmod 777 ${HF_HOME} # Ensure HF_HOME is created and writable
|
| 29 |
# -----------------------------------------------------------------------------------------
|
| 30 |
|
| 31 |
# Copy the rest of your application code into the working directory
|
|
|
|
|
|
|
| 32 |
COPY . .
|
| 33 |
|
| 34 |
# Expose the port that your FastAPI application will run on
|
| 35 |
EXPOSE 8000
|
| 36 |
|
| 37 |
# Command to run your FastAPI application using Uvicorn
|
|
|
|
| 38 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|