It'd be great to use this pattern for setting application specific environment variables with the project. I have used it previously with docker-compose and NodeJS.
https://docs.docker.com/compose/env-file/
https://github.com/motdotla/dotenv#readme
Fwiw, I'm surprised this doesn't work out of the box, since it's supposed to be built in to docker compose?
I'd imagine it would work if I was to use docker-compose, but I'm actually talking about using a .env file to populate values within the Tiltfile.
.env
AWS_ACCESS_KEY_ID=Test
AWS_SECRET_ACCESS_KEY=Test
Titlefile
docker_build('service1', './cmd/service1')
yaml = helm(
'./deployment/helm-charts/service',
name='name',
namespace='namespace',
values=['./deployment/helm-charts/service/values.yaml'],
set=[
'service1.image=service1',
'aws.accessKey=' + os.environ['AWS_ACCESS_KEY_ID'],
'aws.secretKey=' + os.environ['AWS_SECRET_ACCESS_KEY'],
],
)
k8s_yaml(yaml)
ah! ok, that makes sense.
you can do this now with local(), with something like:
aws_access_key_id = str(local('source .env && echo $AWS_ACCESS_KEY_ID')).strip()
though we're working on better primitives for this. does that work?
We've also been suggesting read_json() for this, e.g.
cfg = read_json('config.json')
yaml = helm(
'./deployment/helm-charts/service',
name='name',
namespace='namespace',
values=['./deployment/helm-charts/service/values.yaml'],
set=[
'service1.image=service1',
'aws.accessKey=' + cfg['AWS_ACCESS_KEY_ID'],
'aws.secretKey=' + cfg['AWS_SECRET_ACCESS_KEY'],
],
)
Most helpful comment
I'd imagine it would work if I was to use docker-compose, but I'm actually talking about using a
.envfile to populate values within theTiltfile..env
Titlefile