Tts-api / Dockerfile
yukee1992's picture
Create Dockerfile
402251b verified
raw
history blame
937 Bytes
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV MPLCONFIGDIR=/tmp/matplotlib-cache
# Create cache directories
RUN mkdir -p /tmp/voices /tmp/output $MPLCONFIGDIR && chmod 777 /tmp/voices /tmp/output $MPLCONFIGDIR
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
ffmpeg \
libsndfile1 \
&& 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 application code
COPY app.py .
# Create non-root user
RUN useradd -m -u 1000 user
USER user
# Expose port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/api/health || exit 1
# Run the application
CMD ["python", "app.py"]