Hello all, I'm fairly new to Pulumi (cool platform...
# general
s
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?
Copy code
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
@sticky-airline-40485 did you add
env
to your dockerfile too?
s
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
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
@billowy-army-68599 thanks mate, you're a legend! I was able to get it to work by adding the variables to the
args
,
Copy code
const image = repo.buildAndPushImage({
    context: '..', dockerfile: '../App/Dockerfile', args: {
        'ARG_ASPNETCORE_ENVIRONMENT': 'Dev',
        [...]
    }
})
And then then binding them in the
Dockerfile
Copy code
FROM base AS final
ARG ARG_ASPNETCORE_ENVIRONMENT
ENV ASPNETCORE_ENVIRONMENT=$ARG_ASPNETCORE_ENVIRONMENT
[...]
Thank you again for the guidance!