| # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker | |
| # you will also find guides on how best to write your Dockerfile | |
| # Use a stable and available Python version | |
| FROM python:3.11 | |
| # Install ffmpeg | |
| RUN apt-get update && apt-get install -y ffmpeg | |
| # Create a non - root user | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Set the working directory | |
| WORKDIR /app | |
| # Copy the requirements file | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy all files from the build context to the container | |
| COPY --chown=user . /app | |
| # Set permissions for all files and directories | |
| RUN find /app -type f -exec chmod 644 {} \; && \ | |
| find /app -type d -exec chmod 755 {} \; | |
| # Set the command to run your application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |