feat: true zero-downtime deployment with request draining
Changes:
- Add
--pre-stop-hookargument. - Describe in README how to setup a true zero-downtime deployment.
Notes:
- Hook name "pre-stop" (instead of "before-stop") is inspired by watchtower hooks. This way other hooks can be named "post-stop" etc
- I decided not to add other hooks yet - we will add them when somebody reports a need with a valid use case
- I think it's better to implement draining with an explicitly written command in a hook, rather than a flag like
--drainwith the same implementation, so users can actually understand the process
Close #21, #32.
Thanks, @wowu. This looks fantastic! I'm looking forward to the rollout of this feature. 🚀
What a great timing, I literally adopted this in my project solving exactly this issue, thinking it was a feature since the start, but I somehow missed it when I did the original implementation - but no, it was just merged 15min before me going to look for something like it.
Thank you both :)
@jippi I'm really glad it's useful since day 1 😄
Can you tell me more about your use case? How are you running docker-rollout?
@wowu I'm using it on MangaBaka which is an app built with SvelteKit.
I run 3 x web containers and 3 x API containers, and want them to roll out without dropping traffic.
They are fronted by nginx-proxy that handles everything else.
Implementation wise, I raw copy+pasted the config from the docs and adjusted the sleep to my settings - worked flawlessly and extensive load testing shows 0 dropped or failed requests.
Cool! And how do you build and deploy and new container versions? I wonder how docker rollout fits in the process, is it used as a part of a deploy script or CI/CD pipeline?
I deploy to a single host via GitLab CI runners :)
Cool, thanks for sharing 😃