Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
clementgoclock opened this issue Apr 29, 2024 · 4 comments

Comments

@clementgoclock
Copy link

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.

@Xeckt
Copy link

Xeckt commented Apr 30, 2024

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?

@ndeloof
Copy link
Contributor

ndeloof commented Apr 30, 2024

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

@clementgoclock
Copy link
Author

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.

@ndeloof
Copy link
Contributor

ndeloof commented Apr 30, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants