File size: 1,031 Bytes
1d1f8e0 402251b 70d76ff 1d1f8e0 70d76ff 1d1f8e0 70d76ff 1d1f8e0 70d76ff 402251b 70d76ff 402251b 70d76ff 402251b 6231f89 41b04a0 402251b 1d1f8e0 d428807 eb9f2ca | 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 | FROM python:3.10-slim
WORKDIR /app
# Set environment variables for cache control
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV HF_HOME=/tmp/huggingface
ENV TORCH_HOME=/tmp/torch
ENV COQUI_TOS_AGREED=1
ENV TTS_HOME=/tmp/tts_models
# Create cache directories
RUN mkdir -p /tmp/tts_models /tmp/huggingface /tmp/torch /tmp/voices /tmp/output && \
chmod 777 /tmp/tts_models /tmp/huggingface /tmp/torch /tmp/voices /tmp/output
# Install only essential packages
RUN apt-get update && apt-get install -y \
curl \
ffmpeg \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy requirements
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 7860
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/api/health || exit 1
CMD ["python", "app.py"] |