Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758# Stage 1: Install all dependenciesFROM python:3.9-slim as builderWORKDIR /app# 1. Install system dependenciesRUN apt-get update && \apt-get install -y --no-install-recommends \gcc \python3-dev \&& rm -rf /var/lib/apt/lists/*# 2. Create and activate virtual environmentRUN python -m venv /opt/venvENV PATH="/opt/venv/bin:$PATH"# 3. Install Python packagesCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt# Stage 2: Create lightweight runtime imageFROM python:3.9-slimWORKDIR /app# 1. Install runtime dependenciesRUN apt-get update && \apt-get install -y --no-install-recommends \ffmpeg \&& rm -rf /var/lib/apt/lists/*# 2. Copy virtual environment from builderCOPY --from=builder /opt/venv /opt/venvENV PATH="/opt/venv/bin:$PATH"# 3. Copy application filesCOPY app.py audio_generator.py ./# 4. Create output directoryRUN mkdir -p /app/tts_outputs && \chmod 777 /app/tts_outputs# 5. Environment configurationENV PYTHONUNBUFFERED=1 \PORT=7860# 6. HealthcheckHEALTHCHECK --interval=30s --timeout=10s \CMD curl -f http://localhost:${PORT}/health || exit 1EXPOSE ${PORT}# 7. Run as non-root userRUN useradd -m ttsuser && \chown -R ttsuser /appUSER ttsuserCMD ["python", "app.py"]1234567891011FROM python:3.9-slimWORKDIR /appCOPY requirements.txt .RUN apt-get update && apt-get install -y ffmpeg && \pip install --no-cache-dir -r requirements.txtCOPY . .CMD ["python", "app.py"]
Dockerfile+4-51