To avoid the problem of maintaining the docker-compose.yml and the .env files we can use merging instead. The docker-compose.yml will be used as the first file and then hydra adds a second file with the templating for the settings it needs to override. The same applies to the .env file.
Mensa uses this concept already at https://github.com/code0-tech/mensa/tree/main/modules/docker/codezero (the original docker-compose.yml and .env is located in the vendor directory and gets merged with docker-compose.actions.yml and docker-compose.override.yml. (The override.env contains secrets and is therefore generated at runtime by terraform instead of being committed to the repository)
See https://docs.docker.com/reference/compose-file/merge/ and https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/
To avoid the problem of maintaining the
docker-compose.ymland the.envfiles we can use merging instead. Thedocker-compose.ymlwill be used as the first file and then hydra adds a second file with the templating for the settings it needs to override. The same applies to the.envfile.Mensa uses this concept already at https://github.com/code0-tech/mensa/tree/main/modules/docker/codezero (the original
docker-compose.ymland.envis located in the vendor directory and gets merged withdocker-compose.actions.ymlanddocker-compose.override.yml. (Theoverride.envcontains secrets and is therefore generated at runtime by terraform instead of being committed to the repository)See https://docs.docker.com/reference/compose-file/merge/ and https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/