Aiaudio / Dockerfile
Athspi's picture
Update Dockerfile
9b71e61 verified
raw
history blame
1.58 kB
# ----------- START Dockerfile -----------
# Use an official Python runtime as a parent image
FROM python:3.10
# Set the working directory in the container
WORKDIR /app
# Set environment variables
# - PYTHONUNBUFFERED: Ensures Python output is sent straight to terminal without buffering
# - HF_HOME: Specifies where Hugging Face models/datasets should be cached INSIDE the container
ENV PYTHONUNBUFFERED=1 \
HF_HOME=/app/hf_cache
# Install system dependencies
# - ffmpeg: Required by pydub
# - build-essential: May be needed for compiling some Python dependencies
# - git: Sometimes needed if pip installs from git repositories
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
build-essential \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the container
COPY requirements.txt .
# Install Python dependencies
# Upgrade pip first, use --no-cache-dir to reduce image size
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the model download script BEFORE the main app code
COPY download_models.py .
# Run the model download script during the build process
# This downloads models into the HF_HOME directory defined above
# NOTE: This step can take a LONG time and requires network access during build
RUN python download_models.py
# Copy the rest of the application code into the container
COPY app.py .
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
# ----------- END Dockerfile -----------