# Dockerfile | |
# 1. Choose a base Python image | |
FROM python:3.9-slim | |
# 2. Set the working directory inside the container | |
WORKDIR /code | |
# 3. (Optional but recommended) Install system dependencies if needed | |
# Example: If yt-dlp needs ffmpeg for specific audio conversions later | |
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && apt-get clean && rm -rf /var/lib/apt/lists/* | |
# 4. Copy the requirements file first (for Docker layer caching) | |
COPY ./requirements.txt /code/requirements.txt | |
# 5. Install Python dependencies | |
RUN pip install --no-cache-dir --upgrade pip | |
RUN pip install --no-cache-dir --requirement /code/requirements.txt | |
# 6. Copy the rest of your application code into the container | |
COPY . /code/ | |
# For larger projects, you might copy specific files instead of '.' | |
# 7. Expose the port the application will run on (HF Spaces expects 7860 usually) | |
EXPOSE 7860 | |
# 8. Specify the command to run your application using uvicorn | |
# main: the Python file name (main.py) | |
# app: the FastAPI instance variable name inside main.py (app = FastAPI()) | |
# --host 0.0.0.0: Makes the server accessible from outside the container | |
# --port 7860: The port to listen on | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |