I want to add a volume to my service, but only if the final user gave a folder for it. Otherwise, no volume should be mounted, for the already-prepared image has valid data in a default folder.
That is, I want to do something like; pseudocode:
services:
my_awesome_service:
volumes:
if ${VARIABLE} => ${VARIABLE}:/app/folder
Is establishing such a conditional statement doable and definable in a docker-compose file? The only way I see to make this possible is to first define a base docker-compose file, which does not have the volume mount, and the call on a second docker-compose file only if the $VARIABLE is defined. This is fine for a single or few conditions but gets nasty if there are many.
Any solution?