Spaces:
Build error
Build error
File size: 1,788 Bytes
46e40c5 76b8150 2f806ee cf42333 fe3cab4 9eb8f66 cc387f0 2f806ee cc387f0 9eb8f66 fe3cab4 cc387f0 fe3cab4 9eb8f66 d4cfc39 fe3cab4 489316d fe3cab4 489316d fe3cab4 489316d 2f806ee fe3cab4 489316d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# 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"] |