Skip to content

Add Docker healthcheck for Flux - #24

Merged
10k11 merged 2 commits into
10k11:mainfrom
localhost969:issue-19-docker-healthcheck
Nov 7, 2026
Merged

10k11 merged 2 commits into
10k11:mainfrom
localhost969:issue-19-docker-healthcheck

Conversation

@localhost969

Copy link
Copy Markdown
Contributor

Summary

  • add a Docker HEALTHCHECK using Node's built-in fetch against /api/health
  • document how to verify the container reaches healthy in the Deployment section

Validation

  • npm run check
  • git diff --check
  • docker build --tag flux-healthcheck-test .

Closes #19

@10k11 10k11 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks a lot for the PR, and welcome! 🎉 This is a clean, focused change and the README note is a nice touch.

There is one problem I'd like to fix before merging: this healthcheck will report unhealthy in private mode.

Compose defaults to private mode (FLUX_ACCESS_PASSWORD set, FLUX_PUBLIC_OPEN=0). In server.mjs the HTTP Basic gate (around lines 766-787) runs before the /api/health route, and the healthcheck sends no credentials. It gets a 401, so !response.ok exits 1 and the container never becomes healthy. That misses the issue's "shows healthy after startup" goal for the default setup. (It would pass in public mode, which is probably how it was tested.)

Suggested fix, still Dockerfile-only: send Basic auth from the container's own environment when a password is set. As a bonus, this can also require ready: true, since /api/health returns 200 even when yt-dlp or FFmpeg is missing:

HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 CMD ["node","-e","const h={};if(process.env.FLUX_ACCESS_PASSWORD)h.authorization='Basic '+Buffer.from((process.env.FLUX_ACCESS_USERNAME||'flux')+':'+process.env.FLUX_ACCESS_PASSWORD).toString('base64');fetch('http://127.0.0.1:3000/api/health',{headers:h}).then(r=>r.json().then(j=>process.exit(r.ok&&j.ready?0:1))).catch(()=>process.exit(1))"]

Please verify both modes with docker compose up -d --build and docker compose ps:

  1. with FLUX_ACCESS_PASSWORD set, and
  2. with FLUX_PUBLIC_OPEN=1 and no password.

Both should show healthy. Once that's done I'll approve the CI run and merge. Thanks again!

@localhost969

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback. The healthcheck now sends Basic auth from FLUX_ACCESS_USERNAME/FLUX_ACCESS_PASSWORD when configured and requires /api/health to return ready: true. Verified Docker images in both private-password and public-open modes; both reached healthy after startup.

@10k11 10k11 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, that's exactly the fix. Approving. I'll merge once CI is green.

@10k11
10k11 merged commit 2a248fe into 10k11:main Nov 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Docker healthcheck using /api/health

2 participants