# Restore full pre-retirement app + patch frontend + backend models + auto-continue V17 + auto-approve + document uploads FROM node:20-alpine AS frontend-builder RUN apk add --no-cache git python3 RUN git clone --depth 1 https://huggingface.co/spaces/smolagents/ml-intern /source # Restore the pre-retirement full app (upstream retired it: App.tsx -> RetirementPage, # backend/start.sh -> retired_main:app). This puts back the full UI + real backend # BEFORE our model patches run, so they take effect again. COPY patch_restore_full_app.py /tmp/patch_restore_full_app.py RUN python3 /tmp/patch_restore_full_app.py # Patch frontend: add OpenRouter models COPY patch_frontend.py /tmp/patch_frontend.py RUN python3 /tmp/patch_frontend.py # Patch frontend: add stealth/space-bunny-alpha COPY patch_space_bunny.py /tmp/patch_space_bunny.py RUN python3 /tmp/patch_space_bunny.py # Patch frontend: multi-format file uploads (PDF/images/Excel/Word/PPT/ODF/text) COPY patch_frontend_uploads.py /tmp/patch_frontend_uploads.py RUN python3 /tmp/patch_frontend_uploads.py # Patch frontend: multi-file uploads (many images/files at once) COPY patch_frontend_multi.py /tmp/patch_frontend_multi.py RUN python3 /tmp/patch_frontend_multi.py # Patch frontend: add 3 new OpenRouter models COPY patch_frontend_new_models.py /tmp/patch_frontend_new_models.py RUN python3 /tmp/patch_frontend_new_models.py # Patch auto-continue V17 COPY patch_auto_continue_v17.py /tmp/patch_auto_continue_v17.py RUN python3 /tmp/patch_auto_continue_v17.py WORKDIR /source/frontend RUN npm config set fetch-timeout 120000 && \ npm config set fetch-retries 3 && \ npm install && \ npm run build # Stage 2: Production FROM python:3.12-slim COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ RUN useradd -m -u 1000 user WORKDIR /app # System deps: git/curl/ca-certificates plus document parsing tools. # tesseract-ocr -> OCR for image uploads (with eng + vie language packs) # libreoffice-writer + libreoffice-calc + libreoffice-impress # -> legacy/OpenDocument formats (.xls, .doc, .odt, .ods, .odp, .rtf) RUN apt-get update && apt-get install -y --no-install-recommends \ git curl ca-certificates \ tesseract-ocr tesseract-ocr-eng tesseract-ocr-vie \ libreoffice-writer libreoffice-calc libreoffice-impress \ && rm -rf /var/lib/apt/lists/* RUN git clone --depth 1 https://huggingface.co/spaces/smolagents/ml-intern /tmp/source && \ cp /tmp/source/pyproject.toml /tmp/source/uv.lock ./ && \ cp -r /tmp/source/agent ./agent && \ cp -r /tmp/source/backend ./backend && \ cp -r /tmp/source/configs ./configs && \ cp -r /tmp/source/scripts ./scripts && \ rm -rf /tmp/source # Restore pre-retirement backend entrypoint (start.sh -> uvicorn main:app instead of retired_main:app) COPY patch_restore_full_app.py /tmp/patch_restore_full_app.py RUN python3 /tmp/patch_restore_full_app.py RUN uv sync --no-dev --frozen # Document parsing Python deps (PDF, images/OCR, Excel, Word, PPT, OpenDocument (ODT/ODS/ODP, RTF) RUN uv pip install --python /app/.venv/bin/python \ pypdf \ python-docx \ openpyxl \ python-pptx \ pytesseract \ Pillow COPY --from=frontend-builder /source/frontend/dist ./static/ COPY configs/frontend_agent_config.json ./configs/frontend_agent_config.json # Document text extractor module used by the backend upload route COPY backend/document_parser.py /app/backend/document_parser.py # Patch backend: accept new model IDs COPY patch_models.py /tmp/patch_models.py RUN python /tmp/patch_models.py # Patch backend: add 3 new OpenRouter models COPY patch_new_models.py /tmp/patch_new_models.py RUN python /tmp/patch_new_models.py # Patch backend: fix OpenRouter provider resolution (custom_llm_provider) COPY patch_openrouter_fix.py /tmp/patch_openrouter_fix.py RUN python /tmp/patch_openrouter_fix.py # Patch backend: auto-continue detection + auto-approve COPY patch_agent_backend.py /tmp/patch_agent_backend.py RUN python /tmp/patch_agent_backend.py # Patch backend: multi-format document uploads + text extraction COPY patch_document_upload.py /tmp/patch_document_upload.py RUN python /tmp/patch_document_upload.py # Patch backend: multi-file uploads (many files per request) COPY patch_multi_upload.py /tmp/patch_multi_upload.py RUN python /tmp/patch_multi_upload.py RUN mkdir -p /app/session_logs && chown -R user:user /app USER user ENV HOME=/home/user \ PYTHONUNBUFFERED=1 \ PYTHONPATH=/app \ PATH="/app/.venv/bin:$PATH" EXPOSE 7860 WORKDIR /app/backend CMD ["sh", "start.sh"]