subprocess5 / Dockerfile
sreepathi-ravikumar's picture
Update Dockerfile
9a41c54 verified
raw
history blame
1.16 kB
# Stage 1: Builder
FROM python:3.9-slim as builder
WORKDIR /app
COPY requirements.txt .
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --user --no-cache-dir -r requirements.txt
# Stage 2: Runtime
FROM python:3.9-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Copy Python dependencies
COPY --from=builder /root/.local /root/.local
COPY --from=builder /app/requirements.txt .
# Application files
COPY app.py audio_generator.py ./
# Create output directory with correct permissions
RUN mkdir -p /app/tts_outputs && \
chmod 777 /app/tts_outputs
# Environment configuration
ENV PATH=/root/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
PORT=7860
# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s \
CMD curl -f http://localhost:${PORT}/health || exit 1
EXPOSE ${PORT}
# Run as non-root user
RUN useradd -m ttsuser && \
chown -R ttsuser /app
USER ttsuser
CMD ["python", "app.py"]