feat: add a Docker HEALTHCHECK and document container probes
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- docker, python
- Domain
- devops, documentation
Research direction
Start in the runtime stage of the Dockerfile, where EXPOSE 8000 and the ENTRYPOINT (which passes --port 8000) live, and read src/tserve/server/serve.py around line 46 to see why /health only answers after bootstrap. Add the HEALTHCHECK from the issue, then document it in docs/server/docker.md. Settle the open port and start-period points first, since they decide the final check. Done means the container reports healthy on /health and the docs cover docker ps, inspect, Compose and Kubernetes probes.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
The Docker images have no HEALTHCHECK. The runtime stage of the Dockerfile only has EXPOSE 8000 and the ENTRYPOINT, so docker ps and Compose never report the container as healthy. A Compose service that uses depends_on: condition: service_healthy can't wait for TServe.
This matters more than usual because of how TServe starts. Server.__init__ runs bootstrap(), which downloads, loads and warms up every model before uvicorn.run binds the port (src/tserve/server/serve.py:46). On a first start that can take minutes, and the port stays closed the whole time. From outside, a container that is still downloading weights looks the same as one that has hung.
Because of that ordering, once GET /health answers, every requested model is already loaded and warm. That makes /health a correct readiness signal today. Nothing uses it that way yet.
Describe the solution you'd like
-
Add a
HEALTHCHECKto the runtime stage of theDockerfile. The slim image has nocurl, so use the venv's Python:HEALTHCHECK --interval=30s --timeout=5s --start-period=10m --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=4)"The long
--start-periodcovers first-start weight downloads. Failures during the start period don't count against--retries, and the container is marked healthy as soon as the first check passes, so a warm start isn't delayed. -
Document it in
docs/server/docker.md:- how to read the status (
docker ps,docker inspect) - a Compose
depends_on: condition: service_healthyexample - matching Kubernetes probes: a
startupProbewith a largefailureThresholdfor the download, plusreadinessProbeandlivenessProbeon/health
- how to read the status (
Open points
- Port. The
ENTRYPOINTpasses--port 8000, but a user can override it by appending--port 9000, and the check would then fail. One option is to read the port from an env var (for exampleTSERVE_PORT, defaulting to 8000) in both the entrypoint and the check. Another is to document that the check assumes 8000. - Default
--start-period. A cached-weights start takes seconds and afullcold start can take far longer. 10m is a guess, and users can override it withdocker run --health-start-period.
Describe alternatives you've considered
Bind the port first and load models in the background, with a /ready endpoint that returns 503 until loading and warmup finish. That would give a true startup signal, but it changes the documented "models load before the port is bound" behaviour. It's a bigger change for a separate discussion. The HEALTHCHECK is useful either way.
Additional context
No change to the HTTP API or the Python package. Only the Dockerfile and the docs change.
- Dominant language
- Python
- Stars
- 22
- Forks
- 7
- Avg merge
- 10d 10h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sktime/tserve
-
feat: implement `pytorch-forecasting` executorPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount duePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 79/100
developmentseed/titiler-covjson#164 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
awslabs/visual-asset-management-system#2164 ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
MakazhanAlpamys/Soup#3589 ·
Maintainers usually reply within 1 day
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocketOpen
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day