The docker-compose will automatically read the .env file if it resides in a same with the docker-compose.yml directory. With this in mind, I go ahead and in .env file define the app-container environment variable to store the container URL, like so:
app-container=12345.dkr.ecr.us-west-2.amazonaws.com/container-image:v003
In a docker-compose.yml file I then substitute the container URL with the environment variable app-container.
version: '3'
services:
app1:
build:
context: .
dockerfile: my.dockerfile
image: ${app-container}
It would be great if I could pass the same app-container environment variable to substitute the container's URL defined in Helm's values.yaml file. So, instead of storing the container's URL explicitly
app:
image: 12345.dkr.ecr.us-west-2.amazonaws.com/container-image:v003
the Helm's values.yaml file could use the same app-container environment variable that was already defined in .env file and used by docker-compose. The Helm's values.yaml file could be then simply defined as:
app:
image: ${app-container}
I wonder if sharing the same env file between docker-compose and Helm is possible?
Try this, its little hacky way:
.env file.$ cat .env
appcontainer=12345.dkr.ecr.us-west-2.amazonaws.com/container-image:v003
$ while read LINE; do export "$LINE"; done < .env
NOTE: You need to remove - from app-container name. Otherwise you will get this error while setting environment variable bash: export: app-container=12345.dkr.ecr.us-west-2.amazonaws.com/container-image:v003': not a valid identifier
--set option.helm install --set app.image=$appcontainer ./mychart
But ideally it would be good to have separate env for your docker-compose and helm chart.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With