Reputation: 541
We are developing a small project consisting of a mongodb, java backend and express-js based front-end. We've chose docker-compose
as a deployment tool for all but production uses and so far it's been fairly good with one exception.
Currently, we use it for:
To handle all those various tweaks per environment we've deduced a set of docker-compose files: docker-compose.yml
, d-c.override.yml
, d-c.test.yml
, d-c.load.yml
and d-c.demo.yml
(docker-compose
replaced with d-c
for brevity).
This makes us use enourmously long command-line invocations to do anything except for basic tasks. For example:
docker-compose -f docker-compose.yml -f docker-compose.test.yml up -d --build
docker-compose -f docker-compose.yml -f docker-compose.test.yml exec test_container ./do_tests.sh
And it goes worse.
So far we've got couple ideas about improving that:
extends
for services and minimize the copy-paste (but adds extra complexity);Makefile
(or a bash script). Ease of use, but feels like sweeping complexity under the rug;All of those ideas have their drawbacks -- I wonder what are proper solutions for that and what tools already exist.
Upvotes: 2
Views: 2966
Reputation: 28090
I think 3 sounds like a good solution. It's not "hiding complexity", it's just automating a repetitive task (typing long command lines).
A Makefile would work, but you might also be interested in dobi (disclaimer: I am the author of this tool). dobi
allows you to define all your project tasks in a yaml file, including running Compose with different files and project name. An example config for your project might look something like this
compose=dev:
files: [docker-compose.yaml, d-c.override.yml]
compose=test:
files: [docker-compose.yaml, d-c.test.yml]
compose=load:
files: [docker-compose.yaml, d-c.load.yml]
Then you can run a task with dobi dev
, etc.
You might even find that some of the one-off tasks can be moved to the dobi config, removing the need to have extra compose overrides.
Upvotes: 1