# Stage 1: Build dependencies in a full-featured Python image FROM python:3.11-alpine AS builder WORKDIR /subgen # Install dependencies required for building wheels RUN apk add --no-cache \ ffmpeg \ git \ build-base \ python3-dev \ libffi-dev # Copy and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir --prefix=/install -r requirements.txt # Stage 2: Create a minimal final image FROM python:3.11-alpine WORKDIR /subgen # Install runtime dependencies (minimal set) RUN apk add --no-cache ffmpeg git # Copy only the required files from the builder stage COPY --from=builder /install /usr/local COPY launcher.py subgen.py language_code.py /subgen/ # Set environment variable for cleaner output ENV PYTHONUNBUFFERED=1 # Run the application CMD ["python3", "-u", "launcher.py"]