fastapi-asr-app / Dockerfile
ogflash's picture
Fix: huggingface cache permissions
69e578b
# Use an official Python runtime as a parent image, optimized for CPU
FROM python:3.11-slim-buster
# Set the working directory inside the container
WORKDIR /app
# --- Set Hugging Face cache directory to a writable location within the WORKDIR ---
ENV HF_HOME /app/.cache/huggingface
# ----------------------------------------------------------------------------------
# Install ffmpeg, which is required by pydub.
# We also clean up the apt cache to reduce image size.
RUN apt-get update && \
apt-get install -y ffmpeg && \
rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the working directory first
COPY requirements.txt .
# Install all Python dependencies from requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# --- Create and set appropriate permissions for all directories used by the application ---
# This includes the new HF_HOME path and your app-specific directories.
RUN mkdir -p uploads && chmod 777 uploads
RUN mkdir -p converted_audio_temp && chmod 777 converted_audio_temp
RUN mkdir -p transcriptions && chmod 777 transcriptions
RUN mkdir -p ${HF_HOME} && chmod 777 ${HF_HOME} # Ensure HF_HOME is created and writable
# -----------------------------------------------------------------------------------------
# Copy the rest of your application code into the working directory
COPY . .
# Expose the port that your FastAPI application will run on
EXPOSE 8000
# Command to run your FastAPI application using Uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]