env secrets during container build
# 🌱|help-and-getting-started
e
I'm trying to build a Container and the Dockerfile needs a cluster secret to build (NPM_TOKEN to contact a private repo). So how can I inject secrets into a container build? The documentation link for Build -> Container on the docker.io site appears to not be working so I'll take any help here instead. I've tried
env
,
spec.env
and
spec.spec.env
hoping one might work but no luck. TIA!
b
Hey! @eager-yacht-45658, just one question are you using 0.13 or Acorn? Just to provide a more accurate solution. First thing you’ll need is add an ARG in the Dockerfile that accepts the NPM_TOKEN as an argument. Then Garden moduled have a field called buildArgs: NPM_TOKEN: ${local.env.NPM_TOKEN} I would suggest using it that way so you don’t accidentally commit the token to your repo
e
@bright-policeman-43626 thanks - using 0.13 - and I understand that part; how do i get a secret to set the value of NPM_TOKEN during the build step?
b
You can export it on your bash profile by using export NPM_TOKEN=your-token
And then use the buildArgs block!
e
^ excellent @bright-policeman-43626 thank u!
b
Please let me know if that fixed the issue! In Bonsai you can find buildArgs under .spec in the Build action
2 Views