Hi quick question around environment variables. w...
# getting-started
y
Hi quick question around environment variables. we're using the dockerized version of meltano. when setting environment variables which takes precedence - variables defined in meltano .env vs the same variables defined in dockerfile via ENV?
w
https://docs.meltano.com/guide/configuration/#environment-variables Environment variables from the environment of the process (e.g. from ENV directives in the Dockerfile) have the lowest precedence, and can be overwritten by those from within a
.env
file. The environment variables from a
.env
file have the second lowest precedence
This means that you can have environment variables within your
.env
file that make use of environment variables from the environment of the process, e.g. the following line could go within a
.env
file:
Copy code
MY_ENV_VAR="prefix-${MY_ENV_VAR}-suffix"
y
we're trying to structure our dockerfile to be used during local dev and production - where in local dev we read in the variables from our
.env
file but during production we want to supply during build time by fetching from our secrets backend so that it'll be available in the container to use.
Copy code
ARG MELTANO_IMAGE=meltano/meltano:v2.20.0-python3.9

# setting default env values
ARG TAP_PAGERDUTY_TOKEN
ARG TAP_ORBIT_API_KEY
ARG TAP_STATUSPAGE_API_KEY
ARG TAP_AIRTABLE_TOKEN
ARG TAP_CIRCLECI_TOKEN

FROM $MELTANO_IMAGE

# setting env vars
ENV TAP_PAGERDUTY_TOKEN=${TAP_PAGERDUTY_TOKEN}
ENV TAP_ORBIT_API_KEY=${TAP_ORBIT_API_KEY}
ENV TAP_STATUSPAGE_API_KEY=${TAP_STATUSPAGE_API_KEY}
ENV TAP_AIRTABLE_TOKEN=${TAP_AIRTABLE_TOKEN}
ENV TAP_CIRCLECI_TOKEN=${TAP_CIRCLECI_TOKEN}
locally we have an
.env
file populated with these keys but when this builds and i run a
printenv
in the container it seems that the values do not get overwritten by the values in
.env
for example:
Copy code
TAP_AIRTABLE_TOKEN=
PYTHON_SETUPTOOLS_VERSION=58.1.0
HOME=/root
LANG=C.UTF-8
TAP_PAGERDUTY_TOKEN=
maybe i'm approaching this wrong but any help would be greatly appreciated
for ref we're using the docker and dockercompose file bundles https://github.com/meltano/files-docker-compose/tree/main/bundle