https://garden.io logo
#🌱|help-and-getting-started
env secrets during container build
e

eager-yacht-45658

06/15/2023, 6:33 PM
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

bright-policeman-43626

06/15/2023, 8:24 PM
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

eager-yacht-45658

06/16/2023, 11:51 AM
@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

bright-policeman-43626

06/16/2023, 12:46 PM
You can export it on your bash profile by using export NPM_TOKEN=your-token
And then use the buildArgs block!
e

eager-yacht-45658

06/16/2023, 4:29 PM
^ excellent @bright-policeman-43626 thank u!
b

bright-policeman-43626

06/16/2023, 4:30 PM
Please let me know if that fixed the issue! In Bonsai you can find buildArgs under .spec in the Build action
2 Views