compose icon indicating copy to clipboard operation
compose copied to clipboard

Allow the env_file property in the include attribute to optionally require env files

Open clementgoclock opened this issue 3 months ago • 4 comments

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.

clementgoclock avatar Apr 29 '24 13:04 clementgoclock

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?

Xeckt avatar Apr 30 '24 12:04 Xeckt

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

ndeloof avatar Apr 30 '24 13:04 ndeloof

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 the include 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.

clementgoclock avatar Apr 30 '24 13:04 clementgoclock

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

ndeloof avatar Apr 30 '24 13:04 ndeloof