Hi,
I know that in local mode the environment variables need to be set in the docker-compose file, but I wonder if there’s a way to define environment variables that are common for all services, while services also can have their own settings?
I tried using an .env file like in the following:
version: ‘2’
env_file:
globals.env
services:
my-first-service:
…
but this give this error:
data should NOT have additional properties
Currently we don’t support the env_file attribute in docker-compose.yml. There have been internal discussions to add it, but discussions have stalled. I have added to the discussion internally, and I invite you to upvote this feature request in our roadmap so we can look at assessing its priority.
In the meantime, you can add the env vars under the environment of each service, although this is repetitive. You could automate it with a pre-balena push script which takes a global .env file and interpolates each variable at the correct location in docker-compose.yml.
Hi @bartjanszoon,
we came across a similar issue. We managed to do it that way:
Add your env-variables and value to a file named .env.balena-local
Add the following script element to the package.json file: "balena-local-device": "grep -Ev '^#|^$' .env.balena-local | sed 's/^/--env /' | xargs balena push --debug $@"
Run it from command line using: npm run balena-local-device <deviceUuid>