4 ms·
> I absolutely loathe using it for development environment or testing because of awful design decisions like this wait-for-it hack https://docs.docker.com/compo
by nickjj 6y ago
> I absolutely loathe using it for development environment or testing because of awful design decisions like this wait-for-it hack https://docs.docker.com/compose/startup-order/ https://docs.docker.com/compose/startup-order/
I'd be curious to know which tech stack you're using where you even need to use wait for it.
I've built and worked with various Flask, Django, Rails and Phoenix apps and none of them needed wait-for-it. Most of those ran a web server + background worker + redis + postgres.
Everything starts up no problem in development without any extra tooling when using Docker Compose.
Tests in CI are a different story, but I find wait-for-it to not be the tool to fix that problem. Instead I ended up writing this tiny shell script[0] to wait for a process to be ready between running a docker-compose up -d and running my test suite in CI. You'd run into this issue with or without Docker Compose too.
You could use it to wait until you can do a SELECT 1 on your database (the docs cover multiple database examples). The docs also cover why wait-for-it doesn't work to fix waiting for a database and other common use cases.
[0]: https://github.com/nickjj/wait-until https://github.com/nickjj/wait-until
- pydry 6y agoTests are what I'm concerned about. I tend to do TDD when I develop code and run test suites in CI. I'd rather like something that can orchestrate in a development environment half way competently. I find it hard to believe that docker-compose thinks that "start database, wait for port to be available and then start web server, then wait for port 8080 to be available and then kick off tests" is a workflow that ought to require a hacky bash script and a lecture about the importance of resilience. It's a pretty straightforward feature to implement. I haven't used swarm but I can only imagine how bad that is.
- palkan 6y agoIt’s possible to use health checks for that kind of “wait-for-it”-s. Checkout the configuration here: https://evilmartians.com/chronicles/ruby-on-whales-docker-for-ruby-rails-development https://evilmartians.com/chronicles/ruby-on-whales-docker-fo... Note that it requires using Compose v2.4, not 3.x.
- pydry 6y agough but then you have to use polling instead of epoll. this really isn't ideal if you want to minimize startup time for a test.
- airtonix 6y agoPeople usually need wait-for-it because of terrible design decisions around their "initial data" and "authorative immutable data" made to beat imaginary competitors to market.