compose
compose copied to clipboard
Allow the env_file property in the include attribute to optionally require env files
Description
Following this issue i would like to introduce a feature request about allowing the env_file property in the include attribute to optionally require env files. It'll very much appreciated since i do not want to use env_files on every services from includes files and in the other hand i would like to handle env vars at higher level than specific service.
How are you expecting the required
option to work? If it's false, and the env file doesn't exist, don't worry about it? I don't particularly see the use case given if you don't need it, don't supply it. Can you shed some light?
env_file
property in the include
attribute is only used for interpolation of the included compose model, it has no impact on the services environment
How are you expecting the
required
option to work? If it's false, and the env file doesn't exist, don't worry about it? I don't particularly see the use case given if you don't need it, don't supply it. Can you shed some light?
Yes, as in the service section. If the example.vpn
file doesn't exist, ignore it and run compose. In fact today, if one of the env_file
is missing, I get this error: stat /home/clement/work/repo/teleporter-compose/vpn.env: no such file or directory
.
Use case: if I need another env_file
, e.g. dynamically generated, to import more parameters, I either have to delete the env_file
in compose/include, or touch an empty file. So I need to have the same behavior for everyone and get values for additional services if necessary. In this case, all users can use the project, whether or not they have access to the optional features.
env_file
property in theinclude
attribute is only used for interpolation of the included compose model, it has no impact on the services environment
If I put env_file
in a service attribute, I can't interpolate variables in the environment section of the same service. And since I can't put env_file
in a higher hierarchy, I don't want to pass all the data in the env_file
. Also, I don't want to pass all the data from env_file
to the container, so using good interpolation at the include level makes more sense to me.
Then you don't need env_file
set in your include
, just load your whole compose project with --env-file
flag so values are available for interpolation