$HOME in container build spec.extraFlags
# 🌱|help-and-getting-started
g
Hi 🙂 i need to reference to the user root directory in
kind: Build
type: container
spec.extraFlags
with a value of
- --secret=id=npmrc,src=$HOME/.npmrc
to get credentials for a private npm registry. But i get an error of
Unable to run docker command "build… " $HOME/.npmrc: no such file or directory
But when i copy the hole build command from error message and run it out of
garden dev
or
garden build
just like
docker build
with all garden build args it is working.
can i maybe use a
type: exed
to save the user directory path into a var which i can then use in the build step?
This is working (on unix systems. not sure if it's working on windows machines) 🙂 Workaround:
Copy code
yaml
kind: Run
type: exec
name: my-name
spec:
  command:
    - "echo"
    - "~"
---
kind: Build
…
spec:
  extraFlags:
    - --secret=id=npmrc,src=${actions.run.my-name.outputs.log}/.npmrc
mh, workaroudn is not workig :/ sry
new workaround is createing a shell script which has a content of "echo $HOME" and in the exec calling this file is working 😅 is it somehow possible to print env variables in exec without having such a workaround?
Sometimes it’s much more easy 😅 thank you @bright-policeman-43626 https://discord.com/channels/817392104711651328/1238445088292606013/1238545800687255632
✅ Solution is
Copy code
yaml
kind: Build
…
spec:
  extraFlags:
    - --secret=id=npmrc,src=${local.env.HOME}/.npmrc
b
Oh yeah you definitely went through a rabbit hole, I'm glad you were able to figure it out!