# Use Python 3.10 base image (required for outetts) FROM python:3.10-slim # Set working directory WORKDIR /app # Set environment variables ENV PYTHONPATH="${PYTHONPATH}:/app:/app/yarngpt" ENV HF_HOME="/tmp/huggingface" ENV PYTHONUNBUFFERED=1 # Install system dependencies RUN apt-get update && apt-get install -y \ git \ wget \ curl \ build-essential \ ffmpeg \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy yarngpt folder and other files COPY yarngpt/ ./yarngpt/ COPY main.py . COPY start.sh . # Try to install yarngpt from PyPI as backup RUN pip install yarngpt || echo "PyPI installation failed, using local copy" # Create model download script RUN echo 'import os\n\ import requests\n\ from pathlib import Path\n\ \n\ def download_file(url, filepath):\n\ print(f"Downloading {filepath}...")\n\ response = requests.get(url, stream=True)\n\ response.raise_for_status()\n\ with open(filepath, "wb") as f:\n\ for chunk in response.iter_content(chunk_size=8192):\n\ f.write(chunk)\n\ print(f"Downloaded {filepath}")\n\ \n\ # Create directories\n\ Path("/tmp/huggingface/hub").mkdir(parents=True, exist_ok=True)\n\ \n\ print("Model files will be downloaded during startup...")\n\ print("Setup complete!")' > download_models.py # Run the download script RUN python download_models.py # Make start script executable RUN chmod +x start.sh # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # Expose port EXPOSE 7860 # Start the application CMD ["./start.sh"]