diff --git a/surfsense_backend/Dockerfile b/surfsense_backend/Dockerfile index bb8466ab0..93a923ea3 100644 --- a/surfsense_backend/Dockerfile +++ b/surfsense_backend/Dockerfile @@ -31,6 +31,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ git \ && rm -rf /var/lib/apt/lists/* +RUN which ffmpeg && ffmpeg -version + # Pandoc 3.x from GitHub Releases — apt ships 2.17 which has broken table rendering. # pypandoc_binary bundles pandoc on Windows/macOS; on Linux it picks up this binary. RUN ARCH=$(dpkg --print-architecture) && \ @@ -43,6 +45,7 @@ RUN pip install --upgrade certifi pip-system-certs ENV SSL_CERT_FILE=/usr/local/lib/python3.12/site-packages/certifi/cacert.pem ENV REQUESTS_CA_BUNDLE=/usr/local/lib/python3.12/site-packages/certifi/cacert.pem +ENV SURFSENSE_ALLOW_STATIC_FFMPEG_DOWNLOAD=FALSE # ─── Stage 2: deps (Python deps frozen from uv.lock) ──────────────────────── @@ -82,7 +85,13 @@ RUN mkdir -p /root/.EasyOCR/model && \ (unzip -o craft_mlt_25k.zip || true) # Pre-download Docling models -RUN python -c "try:\n from docling.document_converter import DocumentConverter\n conv = DocumentConverter()\nexcept:\n pass" || true +RUN printf '%s\n' \ + 'try:' \ + ' from docling.document_converter import DocumentConverter' \ + ' DocumentConverter()' \ + 'except Exception:' \ + ' pass' \ + | python || true # Install Playwright browsers (the playwright python package itself is in deps) RUN playwright install chromium --with-deps diff --git a/surfsense_backend/app/config/__init__.py b/surfsense_backend/app/config/__init__.py index f6f0c7f62..724762854 100644 --- a/surfsense_backend/app/config/__init__.py +++ b/surfsense_backend/app/config/__init__.py @@ -473,10 +473,15 @@ def initialize_vision_llm_router(): class Config: # Check if ffmpeg is installed if not is_ffmpeg_installed(): - import static_ffmpeg + allow_static_ffmpeg = ( + os.getenv("SURFSENSE_ALLOW_STATIC_FFMPEG_DOWNLOAD", "TRUE").upper() == "TRUE" + ) + if allow_static_ffmpeg: + import static_ffmpeg + + # ffmpeg installed on first call to add_paths(), threadsafe. + static_ffmpeg.add_paths() - # ffmpeg installed on first call to add_paths(), threadsafe. - static_ffmpeg.add_paths() # check if ffmpeg is installed again if not is_ffmpeg_installed(): raise ValueError(