Skip to content

fix(compose): stop Marker PDF conversion failing with PermissionError#655

Merged
Ahmath-Gadji merged 2 commits into
developfrom
fix/marker-font-path
Jul 15, 2026
Merged

fix(compose): stop Marker PDF conversion failing with PermissionError#655
Ahmath-Gadji merged 2 commits into
developfrom
fix/marker-font-path

Conversation

@Ahmath-Gadji

@Ahmath-Gadji Ahmath-Gadji commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Problem

Every PDF ingestion fails in Marker with:

PermissionError: [Errno 13] Permission denied: '/app/.venv/lib/python3.12/site-packages/static'

Marker downloads its rendering font lazily on the first conversion, defaulting to a path inside the installed package (site-packages/static/fonts/). entrypoint.sh drops the app to a non-root user (APP_UID, GID 0), while the venv lives in the root-owned openrag_venv named volume whose site-packages is root:root drwxr-xr-x. So the app user cannot create static/.

Fix

Point FONT_PATH at /app/data/fonts/, a bind-mounted directory the app user already owns (entrypoint.sh grants GID-0 write on /app/data). The ~15MB download happens once and persists across restarts.

FONT_PATH is the only knob needed: marker's Settings is a pydantic BaseSettings with no env prefix, FONT_DIR is dead except as the default for FONT_PATH, and the two other readers (providers/__init__.py, processors/debug.py) both go through FONT_PATH.

Why the extra anchor

Adding environment: to x-openrag alone silently does nothing for the GPU service: a service's own environment: key replaces the merged one (YAML <<: is shallow), and openrag declares its own. The shared env is hoisted into x-openrag-env so both variants merge it explicitly, and the GPU service's list form is converted to mapping form to allow merging.

Verification

On a live stack, after recreating the container:

  • PDF ingested end-to-end reaches task_state: COMPLETED
  • marker logs Processed /tmp/tmpw2kxewk9.pdf in 33.75s
  • PermissionError count since restart: 0
  • docker compose config confirms FONT_PATH resolves for both openrag and openrag-cpu, and the NVIDIA_* vars survive the list->mapping conversion

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved deployment configuration to ensure fonts are consistently available across related services.
    • Updated GPU-enabled deployments to apply NVIDIA runtime settings more reliably.
    • Enhanced shared environment inheritance for services using the common template, ensuring required environment values are correctly merged.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d825efce-0145-494a-9fde-2464419f0b17

📥 Commits

Reviewing files that changed from the base of the PR and between 16895bd and b817212.

📒 Files selected for processing (1)
  • infra/compose/docker-compose.yaml

📝 Walkthrough

Walkthrough

Docker Compose defines a shared FONT_PATH environment anchor and merges it into the OpenRAG template and GPU service, which retains its NVIDIA environment settings in mapping form.

Changes

Compose environment configuration

Layer / File(s) Summary
Shared environment anchor and service merges
infra/compose/docker-compose.yaml
Adds the shared FONT_PATH anchor and merges it into the OpenRAG template and GPU service alongside NVIDIA_VISIBLE_DEVICES and NVIDIA_DRIVER_CAPABILITIES.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: fix

Suggested reviewers: andyne13, enjoybacon7, hedhoud

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: a compose fix to prevent Marker PDF conversion PermissionError via environment configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/marker-font-path

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the fix Fix issue label Jul 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@infra/compose/docker-compose.yaml`:
- Around line 7-18: FONT_PATH is not consumed by Marker, so the font remains in
the package directory. Update the Marker configuration or conversion path used
by the PDF conversion service to pass the supported font-location override, and
adjust the shared `openrag_env` setting to that supported key.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 066f3af0-662a-4de7-a7da-b523ec651b66

📥 Commits

Reviewing files that changed from the base of the PR and between 760531e and 62ad6df.

📒 Files selected for processing (1)
  • infra/compose/docker-compose.yaml

Comment thread infra/compose/docker-compose.yaml Outdated

@hedhoud hedhoud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall. The compose change fixes the Marker font path in the right place, and the rendered config keeps both the CPU/GPU services covered.

One small non-blocking suggestion: because FONT_PATH is now set directly in environment, it will override any value coming from .env. Could we make it overridable like this?

FONT_PATH: ${FONT_PATH:-/app/data/fonts/GoNotoCurrent-Regular.ttf}

That keeps the default fix exactly the same, but still gives operators an escape hatch if they need to use a custom font path later.

@Ahmath-Gadji

Copy link
Copy Markdown
Collaborator Author

@hedhoud good catch — fixed in b18d896: FONT_PATH: ${FONT_PATH:-/app/data/fonts/GoNotoCurrent-Regular.ttf}. Default behavior is unchanged (verified with docker compose config for both openrag and openrag-cpu), and an operator-set FONT_PATH now overrides it as expected.

hedhoud
hedhoud previously approved these changes Jul 15, 2026

@hedhoud hedhoud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The latest commit fixes the FONT_PATH override concern, and the rendered compose config now keeps the default path while still allowing a custom value from the environment. I also checked the CPU/GPU config render and the infra tests; everything looks good to me.

Ahmath-Gadji and others added 2 commits July 15, 2026 11:32
Marker downloads its rendering font lazily on the first PDF conversion,
and its default target is inside the installed package:

    site-packages/static/fonts/GoNotoCurrent-Regular.ttf

entrypoint.sh drops the app to a non-root user (APP_UID, GID 0) while
the venv lives in the root-owned `openrag_venv` named volume, whose
site-packages is `root:root drwxr-xr-x`. The font download therefore
cannot create `static/` and every PDF ingestion dies with:

    PermissionError: [Errno 13] Permission denied:
      '/app/.venv/lib/python3.12/site-packages/static'

Point FONT_PATH at /app/data/fonts/, a bind-mounted directory the app
user already owns (entrypoint.sh grants GID-0 write on /app/data). The
~15MB download then happens once and persists across restarts.

FONT_PATH is the only knob needed: marker's Settings is a pydantic
BaseSettings with no env prefix, FONT_DIR is dead except as the default
for FONT_PATH, and the two other readers (providers/__init__.py,
processors/debug.py) both go through FONT_PATH.

The shared env is hoisted into its own `x-openrag-env` anchor because a
service's own `environment:` key *replaces* the one merged in via `<<:`
(YAML merge is shallow). Adding it to `x-openrag` alone was silently
dropped by the GPU `openrag` service, which declares its own
`environment:`. Both variants now merge the anchor explicitly, and the
GPU service's list form is converted to mapping form to allow it.

Verified on a live stack: a PDF ingested end-to-end reaches
task_state=COMPLETED, marker logs "Processed ... in 33.75s", and the
PermissionError count since restart is zero.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The x-openrag-env anchor hardcoded FONT_PATH, so it always won over
any value set in .env. Fall back to the same default via ${FONT_PATH:-...}
so operators still have an escape hatch for a custom font location.
@Ahmath-Gadji
Ahmath-Gadji force-pushed the fix/marker-font-path branch from b18d896 to b817212 Compare July 15, 2026 11:33
@Ahmath-Gadji
Ahmath-Gadji merged commit aaa9e85 into develop Jul 15, 2026
6 checks passed
@Ahmath-Gadji
Ahmath-Gadji deleted the fix/marker-font-path branch July 15, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fix issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants