Spaces:
Running
Running
FROM python:3.9-slim | |
# Create a non-root user | |
RUN useradd -m -u 1000 appuser | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
espeak-ng \ | |
git \ | |
libsndfile1 \ | |
curl | |
# Configure environment | |
ENV PYTHONUNBUFFERED=1 \ | |
HF_HOME=/home/appuser/cache \ | |
PYTHONPATH="/app" | |
# Create necessary directories and set permissions | |
RUN mkdir -p /app /home/appuser/cache /home/appuser/.local /home/appuser/.config/pulse && \ | |
chown -R appuser:appuser /app /home/appuser/cache /home/appuser/.local /home/appuser/.config && \ | |
chmod -R 755 /app /home/appuser/cache /home/appuser/.local /home/appuser/.config | |
WORKDIR /app | |
# Copy requirements first for better caching | |
COPY requirements.txt . | |
RUN chown appuser:appuser requirements.txt | |
# Switch to non-root user | |
USER appuser | |
# Install Python dependencies | |
RUN pip install --user --upgrade pip setuptools wheel && \ | |
pip install --user --no-cache-dir -r requirements.txt | |
# Install misaki from source (with data files) | |
RUN pip install --user git+https://github.com/hexgrad/misaki.git --no-cache-dir | |
# Copy application code | |
COPY --chown=appuser:appuser . . | |
# Run FastAPI | |
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |