6 ms·
I've definitely experienced the problems of using Docker Compose for local dev. Oh, that file changed? Control-C to kill the whole cluster. Wait until the DB fl
by freeqaz 5y ago
I've definitely experienced the problems of using Docker Compose for local dev. Oh, that file changed? Control-C to kill the whole cluster. Wait until the DB flushes. Start it again.
And if you just want to restart one service? Well you have to run 4 commands[0] in order to properly do it...
And what the author was saying about needing to "template" the YAML files is also true. In the past, when shipping an Open Source library for others to use, we had to wrap Docker Compose in a CLI that generates the YAML file and then invokes Docker Compose for you. (See it here[1][2][3])
It sucks and this library definitely solves a real problem!
0: https://stackoverflow.com/questions/31466428/how-to-restart-a-single-container-with-docker-compose https://stackoverflow.com/questions/31466428/how-to-restart-...
1: The code: https://github.com/lunasec-io/lunasec/blob/master/js/sdks/packages/cli/src/docker-compose/lunasec-stack.ts https://github.com/lunasec-io/lunasec/blob/master/js/sdks/pa...
2: The package it lives in: https://github.com/lunasec-io/lunasec/tree/master/js/sdks/packages/cli https://github.com/lunasec-io/lunasec/tree/master/js/sdks/pa...
3: The docs for the wrapped CLI: https://www.lunasec.io/docs/pages/overview/demo-app/overview https://www.lunasec.io/docs/pages/overview/demo-app/overview
- afroisalreadyin 5y agoThese are exactly the kinds of issues that drove me to work on miniboss. My top grievance has been the "waiting for service available" issue, which is generally solved by wrapping the dependent code in a `wait-for-it.sh` bash script. A rather hacky solution for a rather simple problem.
- freeqaz 5y agoHahaha yes! I had to add all of that to our code as well. I also had to write a "wait-for-file.sh" script for a mechanism to pass config values. (We use LocalStack to host an AWS env locally and the S3 bucket name is random.) In Docker Compose v2 they had a more sophisticated "depends on" model with health checks, but they removed it in v3. The docs say something about Docker Swarm so I'm guessing they removed that in order to try to make v3 syntax work for clusters too. The real tragedy here is that Kubernetes won, but we're still stuck with Docker Compose trying to be the same thing. I hope your tool can help change this annoying status quo!
- phphphphp 5y agoNot to be a Docker apologist, because I agree they’ve blundered: Docker Compose v3 is actually not the current version of Docker Compose, Docker Compose now uses “the compose specification” which does support service dependencies and it’s trivial to create reliable healthchecks. I totally agree on the tragedy, Docker had so much potential. Very impactful, certainly, but far from what it could have been. I still love it though.
- tln 5y agoWould .env files not have worked? Your script generates a .env, with a static docker-compose.yml Restarting one service isn't 4 commands.
- freeqaz 5y agoIt's potentially possible. I'd have to look at it again to verify. What we were struggling with were "conditional services" like running Integration Tests. We only wanted to add that container to the cluster when we wanted to run the tests. Same with the "demo" mode we added. That spins up an Nginx container with an example front-end app. It's theoretically possible to define all of the containers in one big Docker Compose config and then turn them on/off with env variables per environment, but it's just hellish to debug. In fact, I suspect that's what the engineer that wrote those started with before getting frustrated with spaghetti. Sometimes there is just no winning with the computers lol Edit: Answering the "it isn't 4 commands" bit -- if you just restart a container it won't pick up changes to the Docker Compose config. You have to remove it an add it back to the cluster.
- tln 5y agoThe conditional services can be done with 'profiles' nowadays. https://docs.docker.com/compose/profiles/ https://docs.docker.com/compose/profiles/ Anyway, wrapping everything in a dev command makes a lot of sense for DX, and then if generating docker-compose.yml files or importing miniboss is the most straightforward/reliable/maintainable way, all good Cheers
- qbasic_forever 5y agoIf you're dockerizing a dev environment check out batect, it's kind of like the combo of docker-compose + make (i.e. simple script running) that is really the tool we all just want: https://batect.dev/ https://batect.dev/ It can easily define one-off container tasks like integration test runs with just a couple lines of config.
- freeqaz 5y agoI will check this out. Thank you! I'll also make sure that the "Docker Awesome" list has this info too. I bet there are some cool projects there (and the OPs GitHub project should be added too, come to think of it).
- stingraycharles 5y ago> And if you just want to restart one service? Well you have to run 4 commands[0] in order to properly do it... Care to elaborate? The SO answers seem to indicate it can be done in a single command, and my personal experience confirms that. Are you perhaps also including pulling new images, rebuilding local Dockerfiles, etc etc as part of the “restart service” process?