Skip to content

(feature): docker health checks - #12124

Merged
SchrodingersGat merged 15 commits into
inventree:masterfrom
getpwnam:feature/docker-health-checks
Aug 31, 2026
Merged

SchrodingersGat merged 15 commits into
inventree:masterfrom
getpwnam:feature/docker-health-checks

Conversation

@getpwnam

@getpwnam getpwnam commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Add health checks for each container in docker-compose.yml and updated dependencies to require healthy state in each case.

Container Health Check Condition Dependency
inventree-db pg_isready succeeds None
inventree-cache redis-cli ping succeeds None
inventree-server GET to /api/system/health/ returns HTTP 200 inventree-db and inventree-cache must be healthy
inventree-worker is_worker_running() returns True inventree-server must be healthy
inventree-proxy GET to /api/system/health/ with Host: ${INVENTREE_SITE_URL} returns HTTP 200 inventree-server and inventree-worker must be healthy

Tested on my v1.3.3 instance for around 10 days with no problems to report.

Would appreciate some extra testing/validation from a Docker expert.

Refs: #12122
Refs: #12123

@netlify

netlify Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 8d39dfa
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a950ff143444500086fc001
😎 Deploy Preview https://deploy-preview-12124--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 93 (🟢 up 1 from production)
Accessibility: 82 (no change from production)
Best Practices: 92 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@getpwnam getpwnam changed the title Feature/docker health checks (feature): docker health checks Jun 8, 2026
Comment thread contrib/container/docker-compose.yml Outdated
healthcheck:
test:
[
'CMD-SHELL',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should expose an invoke command to determine the health of the background worker process - which could encapsulate the code her potentially

@SchrodingersGat
SchrodingersGat requested a review from matmair June 9, 2026 11:34
@SchrodingersGat SchrodingersGat added docker Docker / docker-compose setup Relates to the InvenTree setup / installation process labels Jun 9, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member

@getpwnam thanks for submitting this, overall it looks pretty reasonable. What are your thoughts about exposing an internal function (e.g. invoke task) for background worker health check? This makes it a bit more general purpose I think.

Also, do you have any tracing or metrics over the 10 day period you have been running this? In particular what load does a 20s interval impose on the setup?

@SchrodingersGat SchrodingersGat added the enhancement This is an suggested enhancement or new feature label Jun 9, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member

Requested Improvements

  • Update the docker documentation to include information about the health checks
  • Add entry to CHANGELOG.md

@SchrodingersGat

Copy link
Copy Markdown
Member

Refer to this PR - #12193 - for a much more efficient health check for the worker task

@SchrodingersGat

Copy link
Copy Markdown
Member

You can now update this to use the following commands:

  • invoke server-health
  • invoke worker-health

Which should be much simpler

@getpwnam

Copy link
Copy Markdown
Contributor Author

Thank you for these @SchrodingersGat - I'll get those running on my instance for a while and PR.

@SchrodingersGat SchrodingersGat added this to the 1.5.0 milestone Jun 24, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member

@getpwnam great, LMK how you go

@br413

br413 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Hi @getpwnam @SchrodingersGat — I had opened #12419 for #12123 but closed it in favor of this PR.

To help finish the remaining review items here, I have opened a docs/CHANGELOG follow-up:

#12420 — Document Docker Compose container health checks

Changes:

  • docs/docs/start/docker_install.md — new Container Health Checks section (service table, docker compose ps, manual invoke server-health / invoke worker-health)
  • CHANGELOG.md — Unreleased entry referencing this PR

Happy to adjust wording, fold these commits into your branch, or update the docs once the final invoke-based health check commands land here.

@SchrodingersGat

Copy link
Copy Markdown
Member

@getpwnam will you have any time to look into the requested changes?

@SchrodingersGat

Copy link
Copy Markdown
Member

@getpwnam please fix conflicts and use updated commands

Updates server and worker healthchecks to use invoke server-health
and invoke worker-health as requested in inventree#12124 review.

Refs inventree#12124
@br413

br413 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Hi @getpwnam @SchrodingersGat — following the review feedback to switch to invoke server-health / invoke worker-health, I pushed an updated branch you can cherry-pick or merge:

br413/InvenTree help/12124-healthchecks

Changes vs this PR:

  • inventree-server healthcheck: invoke server-health --address "http://localhost:${INVENTREE_WEB_PORT:-8000}"
  • inventree-worker healthcheck: invoke worker-health (replaces inline Django startup check)
  • Keeps your db/redis/caddy healthchecks and depends_on: condition: service_healthy wiring

Docs/CHANGELOG follow-up is still in #12420 (approved by @SchrodingersGat) — happy to fold that in once this lands, or adjust the docs branch to match whatever you merge here.

@getpwnam — if you'd like, I can open a PR against your feature/docker-health-checks branch instead. Just say the word.

@getpwnam

Copy link
Copy Markdown
Contributor Author

Apologies for the delay! Been away with work.
Just ack'ing the comments here - will have a meaningful response within 24h

@SchrodingersGat

Copy link
Copy Markdown
Member

@getpwnam great, looking forward to getting this merged soon!

@getpwnam

getpwnam commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@SchrodingersGat @br413 - opinions please.

invoke server-health --address "http://localhost:$${INVENTREE_WEB_PORT:-8000}"
Works fine, with the assumption that localhost is included in ALLOWED_HOSTS env variable.

As it happens, my prod instance did not - and thus refused to start inventree-server.
My initial thought was to use INVENTREE_SITE_URL instead of localhost - but that will usually require a functioning inventree-proxy container , which presently depends on inventree-server ... so we have a circular dependency.
And we really want healthcheck to be wholly internal to the container under test. (Small exception for caddy)

Just wanted to flag this in case of wider impact. A couple of possible ways forward:

  1. Accept that localhost will always need to be in ALLOWED_HOSTS; add a comment/example in the default .env
  2. Update invoke server-health function to pass the hostname from INVENTREE_SERVER_URL in the HTTP 'Host' header so that ALLOWED_HOSTS is respected.

Number 1 feels like a bit of a shim, so I'd prefer 2.
I pushed changes to implement 2 to feature/docker-health-checks along with a unit test to verify - but interested in your thoughts before going any further.

@SchrodingersGat SchrodingersGat added backport Apply this label to a PR to enable auto-backport action backport-to-1.5.x labels Aug 10, 2026
@SchrodingersGat SchrodingersGat modified the milestones: 1.5.0, 1.6.0 Aug 10, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member

I think that option 2 is much cleaner

Comment thread contrib/container/docker-compose.yml Resolved
@SchrodingersGat

Copy link
Copy Markdown
Member

@matmair I have tweaked the Caddyfile slightly so the health check can be greatly simplified

@SchrodingersGat
SchrodingersGat marked this pull request as ready for review August 28, 2026 06:53
@SchrodingersGat

Copy link
Copy Markdown
Member

@getpwnam any comments before we merge this?

@SchrodingersGat
SchrodingersGat merged commit 773ed4e into inventree:master Aug 31, 2026
32 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
✅ 1.5.x

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

br413 added a commit to br413/InvenTree that referenced this pull request Aug 31, 2026
Reviewed against inventree#12124: server uses invoke server-health, proxy probes Caddy :9090, worker uses invoke worker-health.
SchrodingersGat added a commit that referenced this pull request Aug 31, 2026
* Add Docker container health checks

* Use invoke tasks for Docker container health checks

Updates server and worker healthchecks to use invoke server-health
and invoke worker-health as requested in #12124 review.

Refs #12124

* Added HTTP host check to server health check

* Add health-check endpoint for Caddyfile

* Simplify health check for Caddy

* Remove test file

---------




(cherry picked from commit 773ed4e)

Co-authored-by: getpwnam <[email protected]>
Co-authored-by: Oliver <[email protected]>
Co-authored-by: DESKTOP-691E36A\Administrator <[email protected]>
Co-authored-by: Matthias Mair <[email protected]>
SchrodingersGat pushed a commit that referenced this pull request Aug 31, 2026
* Document Docker Compose container health checks

Add user documentation and CHANGELOG entry for the production
docker-compose health checks proposed in #12124.

* docs: match health-check docs to merged docker-compose.yml

Reviewed against #12124: server uses invoke server-health, proxy probes Caddy :9090, worker uses invoke worker-health.
SchrodingersGat pushed a commit that referenced this pull request Aug 31, 2026
* Document Docker Compose container health checks

Add user documentation and CHANGELOG entry for the production
docker-compose health checks proposed in #12124.

* docs: match health-check docs to merged docker-compose.yml

Reviewed against #12124: server uses invoke server-health, proxy probes Caddy :9090, worker uses invoke worker-health.

(cherry picked from commit fe489bd)

Co-authored-by: Senior Data Engineer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Apply this label to a PR to enable auto-backport action backport-to-1.5.x docker Docker / docker-compose enhancement This is an suggested enhancement or new feature setup Relates to the InvenTree setup / installation process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants