Hi,
I’m interested having some kind of conditional statement for my docker-compose file.
(sorry if this topic already exists somewhere, just give me the link)
My use case:
- my backend compose file includes middlewares required for integration tests (ex. database),
- plus a version of a portal.
- while working locally, I do need the portal to do some manual tests,
- but while testing/releasing under jenkins, I only need middlewares, and so I don’t want portal service to be pulled/started at all.
- I would like to compose something like the following :
Example:
mdw1:
image: mdwr1
mdw2:
image: mdwr2
portal:
image: myportal
rule: if: '$WITH_PORTAL= "1"'
As I understood from StackOverflow (BMich answer) , there is nothing to do that today out of managing multiple docker-compose files.
After seeing issue on github I found this closest question saying that conditional is out-of-scope.
My point is: I would ike to avoid to duplicate the information (eg. mdw part), and avoid managing X docker-compose files to fit my need with extra scripts…so for me conditional statement represent a nice-to-have feature, and I would like to have more details on why it’s rejected.
For gitlab-ci yml, you have “rule” directive that could match that need.
If you think this could be a feature request on github, we could (I could) create a github feature request ?
PS as new user here I can’t post more than 1 link : and there is an issue with the popup saying that > then I were unable to re-edit the content to fix it I would prefer captcha to protect against new user spamming risk…
So reference used are:
- StackOverflow subject: search “docker-compose-conditional-statement-e-g-add-volume-only-if-condition”
- gitlab ci rule : search via docs_gitlab_com then ce/ci/yaml/#rules