I want to send to my build a token to access from the Dockerfile to my private npm repository but Okteto only accepts in the build section the format of file.
In my case Im using Deploy Preview Environments Action from Okteto.
How can I do it?
I want to send to my build a token to access from the Dockerfile to my private npm repository but Okteto only accepts in the build section the format of file.
In my case Im using Deploy Preview Environments Action from Okteto.
How can I do it?
At the moment we only accept it in the format of files: Okteto Manifest Reference | Okteto Documentation
The way to do it is to get the ENV variable value and use it in a file and then pass it to the Dockerfile and export it to ENV variable.
Steps would be:
Add in Admin/Admin Variables in the UI of Okteto an Env called: NPM_TOKEN=mynpmaccesstoken
Then add a file to the repository call for example .npm_token
with the content: $NPM_TOKEN
This will get the value from the UI variable
In the Okteto manifest build
section I get the content of that file:
build:
api:
context: api
secrets:
npmrc: .npm_token
RUN --mount=type=secret,id=npmrc \
export NPM_READONLY_TOKEN=$(cat /run/secrets/npmrc) && echo $NPM_READONLY_TOKEN
Instead of using echo
using your command that will consume the value.