https://pulumi.com logo
Title
o

orange-kite-80991

10/17/2021, 6:00 AM
When building a Docker Image, my args & env values are not showing up in the docker build environment. My Pulumi 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
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

calm-nest-80923

10/17/2021, 10:07 AM
Hope it’s not a red hering - but do you capture the ARGs in the dockerfile? e.g.:
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

orange-kite-80991

10/17/2021, 3:20 PM
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

billowy-army-68599

10/17/2021, 4:57 PM
unfortunately not, this is the only way 😞
o

orange-kite-80991

10/17/2021, 8:59 PM
OK, Thx. Onward, building the links that hold civilisation together!⛓️
💪 1