Skip to content

chore(docker): add HEALTHCHECK against /api/health - #1412

Open
xusnitdinov wants to merge 1 commit into
papra-hq:mainfrom
xusnitdinov:feat/docker-healthcheck
Open

chore(docker): add HEALTHCHECK against /api/health#1412
xusnitdinov wants to merge 1 commit into
papra-hq:mainfrom
xusnitdinov:feat/docker-healthcheck

Conversation

@xusnitdinov

Copy link
Copy Markdown

Summary

  • Adds HEALTHCHECK to apps/papra-server/Dockerfile, packages/app/Dockerfile, and packages/app/Dockerfile.rootless
  • Hits /api/health with Node fetch (already in the image — no curl/jq needed on slim)
  • Exits non-zero when the request fails, returns non-2xx, or status !== \"ok\" (covers the 500 DB-unhealthy path)

Closes #691

Why this approach

Maintainer note on the issue suggested curl -f, but these images are node:*-slim and do not include curl by default. Node 18+ fetch keeps the images unchanged.

Test plan

  • docker build one of the Dockerfiles
  • Run the container and confirm docker inspectState.Health.Status becomes healthy after start-period
  • Break DB / stop the process and confirm health flips to unhealthy

Made with Cursor

Uses Node fetch so slim images do not need curl/jq. Fails when the
endpoint is unreachable, non-2xx, or status is not ok.

Closes papra-hq#691
@xusnitdinov
xusnitdinov requested a review from a team as a code owner August 11, 2026 04:52
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Added Node-based Docker health checks to three application Dockerfiles. Each check polls /api/health, validates the HTTP response and JSON status, and reports failure for request, parsing, HTTP, or health-status errors.

Changes

Docker health checks

Layer / File(s) Summary
Add health endpoint validation
apps/papra-server/Dockerfile, packages/app/Dockerfile, packages/app/Dockerfile.rootless
Each Dockerfile polls /api/health on the configured port or port 1221. The check succeeds only when the HTTP response is successful and the JSON status is ok.

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

Possibly related PRs

  • papra-hq/papra#1392: Adds Docker HEALTHCHECK instructions to the same three Dockerfiles using Node and /api/health.

Suggested reviewers: corentinth

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement the requested health checks in all three Dockerfiles using the existing /api/health endpoint [#691].
Out of Scope Changes check ✅ Passed All changes are limited to Docker health checks and directly support the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely identifies the Docker health check added for the /api/health endpoint.
Description check ✅ Passed The description accurately explains the Dockerfile changes, health check behavior, rationale, linked issue, and test plan.

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 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 `@apps/papra-server/Dockerfile`:
- Around line 59-61: Replace the shell-form HEALTHCHECK CMD with exec-form
JSON-array arguments in apps/papra-server/Dockerfile lines 59-61,
packages/app/Dockerfile lines 61-63, and packages/app/Dockerfile.rootless lines
70-72. Preserve the existing node healthcheck script and behavior while invoking
node directly without shell parsing.
🪄 Autofix

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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 45d13d4f-5c4a-469d-88ac-26e7669ede2c

📥 Commits

Reviewing files that changed from the base of the PR and between d28e3ee and 95106fe.

📒 Files selected for processing (3)
  • apps/papra-server/Dockerfile
  • packages/app/Dockerfile
  • packages/app/Dockerfile.rootless

Comment on lines +59 to +61
# Validate /api/health (node is in the image; avoids curl/jq on slim)
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||1221)+'/api/health').then(async r=>{if(!r.ok)process.exit(1);const j=await r.json();process.exit(j.status==='ok'?0:1)}).catch(()=>process.exit(1))"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use exec-form arguments for the shared healthcheck.

All three Dockerfiles use shell-form HEALTHCHECK CMD commands. Use the JSON-array form to run node without shell parsing. Docker supports this form for healthchecks. (docs.docker.com)

  • apps/papra-server/Dockerfile#L59-L61: replace the shell-form command with CMD ["node", "-e", "..."].
  • packages/app/Dockerfile#L61-L63: replace the shell-form command with CMD ["node", "-e", "..."].
  • packages/app/Dockerfile.rootless#L70-L72: replace the shell-form command with CMD ["node", "-e", "..."].
🧰 Tools
🪛 Hadolint (2.15.1)

[warning] 60-60: Use arguments JSON notation for CMD and ENTRYPOINT arguments

(DL3025)

📍 Affects 3 files
  • apps/papra-server/Dockerfile#L59-L61 (this comment)
  • packages/app/Dockerfile#L61-L63
  • packages/app/Dockerfile.rootless#L70-L72
🤖 Prompt for 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.

In `@apps/papra-server/Dockerfile` around lines 59 - 61, Replace the shell-form
HEALTHCHECK CMD with exec-form JSON-array arguments in
apps/papra-server/Dockerfile lines 59-61, packages/app/Dockerfile lines 61-63,
and packages/app/Dockerfile.rootless lines 70-72. Preserve the existing node
healthcheck script and behavior while invoking node directly without shell
parsing.

Source: Linters/SAST tools

@cla-signer

cla-signer Bot commented Aug 20, 2026

Copy link
Copy Markdown

Contributor License Agreement

Thanks for the contribution! Before this pull request can be merged, everyone who contributed to it has to sign the Papra CLA for it. The agreement should be signed per contributions, so signing for earlier work does not cover this one.

Still to sign: @xusnitdinov

-> Sign the CLA


This check re-runs on its own once you have signed.

@cla-signer cla-signer Bot added the cla: signature required PR cannot be merged due to lack of CLA signature for this contribution label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: signature required PR cannot be merged due to lack of CLA signature for this contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add health check to Dockerfiles

1 participant