Spaces:
Sleeping
Sleeping
| # Stage 1: Build NewPipeExtractor CLI | |
| FROM gradle:8.5-jdk17 AS builder | |
| WORKDIR /app | |
| COPY extractor-cli/ . | |
| RUN gradle shadowJar --no-daemon | |
| # Stage 2: Python server runtime | |
| FROM python:3.10-slim | |
| # Install system dependencies including ffmpeg, curl, and lightweight JRE for running NewPipeExtractor | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| curl \ | |
| default-jre-headless \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install python dependencies globally as root | |
| RUN pip install --no-cache-dir fastapi uvicorn | |
| # Create a non-root user (UID 1000 is default on HF) | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /app | |
| # Copy FastAPI app and compiled jar | |
| COPY app.py . | |
| COPY --from=builder /app/build/libs/extractor-cli.jar extractor-cli.jar | |
| # Set ownership to the non-root user | |
| RUN chown -R user:user /app | |
| # Switch to the non-root user | |
| USER user | |
| # Set PATH to include user local bin just in case | |
| ENV PATH="/home/user/.local/bin:${PATH}" | |
| # Expose port 7860 | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |