Spaces:
Sleeping
Sleeping
| # ============================================================================== | |
| # Stage 1: Build Audiveris from source (needs JDK 25 + Gradle) | |
| # ============================================================================== | |
| FROM eclipse-temurin:25-jdk AS audiveris-builder | |
| RUN apt-get update && apt-get install -y --no-install-recommends git && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Clone Audiveris source | |
| RUN git clone --depth 1 https://github.com/Audiveris/audiveris.git /audiveris | |
| WORKDIR /audiveris | |
| # Build Audiveris (installDist creates bin/ + lib/ with all JARs) | |
| RUN chmod +x gradlew && \ | |
| ./gradlew :app:installDist -x test -x javadoc --no-daemon | |
| # ============================================================================== | |
| # Stage 2: Runtime image (JRE 25 + Python 3.11 + Tesseract) | |
| # ============================================================================== | |
| FROM eclipse-temurin:25-jre | |
| # Install Python, Tesseract, and system deps | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3 \ | |
| python3-pip \ | |
| python3-venv \ | |
| tesseract-ocr \ | |
| tesseract-ocr-eng \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy built Audiveris | |
| COPY --from=audiveris-builder /audiveris/app/build/install/app /opt/audiveris | |
| # Make Audiveris script executable | |
| RUN chmod +x /opt/audiveris/bin/Audiveris | |
| # Set up Python virtual env (HF Spaces best practice) | |
| RUN python3 -m venv /opt/venv | |
| ENV PATH="/opt/venv/bin:$PATH" | |
| # Install Python dependencies | |
| COPY requirements-server.txt /tmp/requirements.txt | |
| RUN pip install --no-cache-dir -r /tmp/requirements.txt | |
| # Copy application code | |
| WORKDIR /app | |
| COPY core/ ./core/ | |
| COPY static/ ./static/ | |
| COPY app_gradio.py . | |
| COPY convert_3part.py . | |
| # Environment variables | |
| ENV AUDIVERIS_BIN=/opt/audiveris/bin/Audiveris | |
| ENV AUDIVERIS_MAX_HEAP=1500m | |
| ENV JAVA_TOOL_OPTIONS="-Djava.awt.headless=true" | |
| ENV MAX_PDF_PAGES=5 | |
| ENV GRADIO_SERVER_NAME=0.0.0.0 | |
| ENV GRADIO_SERVER_PORT=7860 | |
| EXPOSE 7860 | |
| CMD ["python", "app_gradio.py", "--port", "7860"] | |