Download the PHP package brettmc/docker-compose-generator without Composer
On this page you can find all versions of the php package brettmc/docker-compose-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brettmc/docker-compose-generator
More information about brettmc/docker-compose-generator
Files in brettmc/docker-compose-generator
Package docker-compose-generator
Short Description Template-driven docker-compose file generation
License MIT
Homepage https://github.com/brettmc/docker-compose-generator
Informations about the package docker-compose-generator
docker-compose generator
A tool for populating a docker-compose file from one or more templates, using mustache-like replacement.
Installation/usage
Composer package:
Docker image:
Overview
If you need to maintain multiple, slightly-different, docker-compose configurations which change per-environment, you've come to the right place.
This is being used in production in my day job for a couple of medium-sized projects, and is usually used as follows:
- git commit triggers a CI/CD pipeline
- pipeline tests, builds and tags some docker images, ready to be deployed
- pipeline executes a shell script, which tests some variables to work out which environment it is deploying to, and which files it should include:
- tags -> prod env
- develop -> test env
- everything else -> build env
- generate docker-compose config by combining a main template file with one or more environment-specific files, as well as optionally a main and environment-specific .ini file, and finally any dynamic values via the
-eswitch - pass the generated file to
docker stack deploy
Per-environment differences
For example, commits to development branches are built and deployed to a dev swarm. Each dev deployment gets its own database, but test and prod deployments do not.
Multiple input files
Merge multiple yaml templates. For example, a main.yml template can be extended by having dev.yml
add additional services. These will be merged together before applying later operations.
If templates are provided from both stdin and via the --input option, stdin is processed first.
Multiple inputs provided via --input are processed in order.
Variable substitution
After merging all templates, perform variable substitution across the result, based on values from .ini files, then environment variables and finally variables from -e flags.
Define variables in numerous ways
Accepts variables from INI-style environment files, or command switches, in the following order:
.inifiles (eg--ini global.ini --ini local.ini) are processed in the order they are provided, with duplicate keys overriding earlier; then- environment variables; then
- command-line variables (
-e FOO=foo); and finally - nullable command-line variables (
-o FOO=or-o FOO=foo) - if an empty value is given, it is ignored and does not clobber an earlier setting
Usage
main.yml
dev.yml
prod.yml
prod.ini
dev.ini
You can then roll your own logic to work out which files to apply after main.yml, eg
Run via docker
NB, do not attach a TTY (ie, do not use docker's -t switch) if you are piping input
or
or just use volumes:
All versions of docker-compose-generator with dependencies
laminas/laminas-stdlib Version ^3
symfony/yaml Version ^5
symfony/console Version ^5