When building a Docker Image, my args & env va...
# typescript
o
When building a Docker Image, my args & env values are not showing up in the docker build environment. My Pulumi code:
Copy code
export const dockerImage = new docker.Image( appName,  {              
    imageName,
    registry: infra.dockerRegistry,
    build: {
      context,
      env: {
        TEST_PARAM_SIMPLE: 'SimpleParam Value',
        TEST_PARAM_SECRET: `config secret ${config.get('test_param_secret')}`,
      },
      args: {
        TEST_PARAM_PULUMI: `from config ${config.get('test_param_pulumi')}`,
      }
}})
And at the other end in my Dockerfile
Copy code
RUN echo "SIMPLE=$TEST_PARAM_SIMPLE" > test_env_settings
RUN echo "PARAM=$TEST_PARAM_PULUMI" > test_env_settings
RUN echo "Secret=$TEST_PARAM_SECRET" > test_env_settings
RUN env > all_env1
None of my TEST... params show up in any of the outputs. Am I using the wrong incantations?
c
Hope it’s not a red hering - but do you capture the ARGs in the dockerfile? e.g.:
Copy code
ARG TEST_PARAM_PULUMI
RUN echo $TEST_PARAM_PULUMI
test_env_settings
This looks to me like you’re trying to have different env vars for each deployment environment. We switch these using different stacks - Pulumi.<stack-name>.yaml and set different values depending on that. HTH
o
Thanks Armin. That was the syntactic sugar I was missing. Is there a shorter route to routing Pulumi Config variables to Docker Build? Config=>config.get()=>ARGS=>access seems a bit long winded and requiring name consistency across multiple code fragments.
🙌 1
b
unfortunately not, this is the only way 😞
o
OK, Thx. Onward, building the links that hold civilisation together!⛓️
💪 1