-
-
Notifications
You must be signed in to change notification settings - Fork 243
Docker: replace wait_for_database with depends_on and healthcheck #1314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker: replace wait_for_database with depends_on and healthcheck #1314
Conversation
@openbrian Thanks for this! One question: how would waiting for the database work in a "non compose" scenario (for example using kubernetes) ? |
That's a good question. I don't know.
I often find the complexity of Kubernetes doesn't make it worth using.
…--
Brian DeRocher
On September 18, 2023 5:09:03 AM EDT, Yohan Boniface ***@***.***> wrote:
@openbrian Thanks for this!
One question: how would waiting for the database work in a "non compose" scenario (for example using kubernetes) ?
--
Reply to this email directly or view it on GitHub:
#1314 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
I can't argue ;) But some people do use Kubernetes, and do deploy uMap with Kubernetes, so we cannot break the Docker image for them. Maybe a first step would be to keep the script while adding the compose syntax ? cc @jpetazzo in case you have some good practice to suggest here 🙏 |
Seems like the philosophy in Kubernetes is the app must stand on its own 2 feet. From what I've read so far, there is no equivalence to docker-compose depends_on. https://saturncloud.io/blog/understanding-the-equivalent-of-dependson-in-kubernetes/ https://stackoverflow.com/questions/49368047/what-is-the-equivalent-for-depends-on-in-kubernetes kubernetes/kubernetes#117359 - Implement "depends_on" for kind deployment I'll wait for a response from @jpetazzo . If needed, I can put the wait-for script back. But really anything is better than bash, right?! How about a umap command? :) |
Or something like that https://pypi.org/project/django-probes/? :) |
Or maybe https://docs.djangoproject.com/en/4.2/ref/django-admin/#cmdoption-check-database with a loop ? |
Hi! Until recently, Now that Compose supports Unfortunately, Docker healthchecks lack nuance: there is only one type of healthcheck, whereas Kubernetes makes the difference between In Kubernetes, the recommended way to wait for other services is to use an My subjective opinion on the matter would be the following: if switching to a Docker healthcheck (+ |
In fact for another project, I have a docker compose service that only runs a database migration. The app service depends on that migration services on the condition that it successfully completes. I'm going with the django_probes approach because it appears to be written with Kubernetes in mind. |
While django-probes does add a dependency, I feel it's worth it. The core logic is in this file. It checks for the database to be up and stable for 5 seconds. This can be reduced to 0 seconds, meaning if the db is up, just exit the command immediately. Feel free to just add |
Here's a little tip for those using docker-compose... Instead of restarting the container, I often exec a command in there like to just restart (hang up) the app. Always seems to be pid 7 :)
I should probably get my django app into proper debug mode with watching files. How do we do that? |
Thanks for your work on this @openbrian! 👍 And thanks a lot @jpetazzo for your lights, clear as usual ♥ |
I just got started with umap using docker. Even though the entrypoint has a mechanism to wait for the database, it wasn't waiting.
Docker compose now supports depends_on with a healthcheck. I feel it's better to use this declarative configuration over imperative bash.
Side note, if this was the only reason "umap shell" exists, then please also close that entry point to remove the attack vector.