https://pulumi.com logo
Title
s

sticky-airline-40485

10/18/2021, 3:32 PM
Hello all, I'm fairly new to Pulumi (cool platform by the way). I'm trying to create a docker image using Crosswalk w/ Typescript. I can create the image, but the environment variables aren't being set. Any ideas?
const repo = new awsx.ecr.Repository("repo")

const image = repo.buildAndPushImage({
    context: '..', dockerfile: '../App/Dockerfile', env: {
        'ASPNETCORE_ENVIRONMENT': 'Dev',
        'ASPNETCORE_URLS': 'https://+:443',
        'ASPNETCORE_HTTPS_PORT': '443',
    }
})
b

billowy-army-68599

10/18/2021, 4:55 PM
@sticky-airline-40485 did you add
env
to your dockerfile too?
s

sticky-airline-40485

10/18/2021, 10:12 PM
Hi @billowy-army-68599 thanks for your reply. I didn’t add any
ENV
to the Dockerfile. Is that the only way to set them in Pulumi?
b

billowy-army-68599

10/18/2021, 10:13 PM
that's a docker construct, the dockerfile doesn't know you're setting any environment variables at the moment. you might want to give this a read: https://vsupalov.com/docker-arg-env-variable-guide/
s

sticky-airline-40485

10/19/2021, 10:42 AM
@billowy-army-68599 thanks mate, you're a legend! I was able to get it to work by adding the variables to the
args
,
const image = repo.buildAndPushImage({
    context: '..', dockerfile: '../App/Dockerfile', args: {
        'ARG_ASPNETCORE_ENVIRONMENT': 'Dev',
        [...]
    }
})
And then then binding them in the
Dockerfile
FROM base AS final
ARG ARG_ASPNETCORE_ENVIRONMENT
ENV ASPNETCORE_ENVIRONMENT=$ARG_ASPNETCORE_ENVIRONMENT
[...]
Thank you again for the guidance!