Closed knulpi closed 3 years ago
We have had this request come up in the past over on the faas-cli repo. I'll try to link back to it later, or you can search and add the reference here. https://github.com/openfaas/faas-cli/pull/364 https://github.com/openfaas/faas-cli/issues/255
Adding a .npmrc
file with credentials to private npm repos is almost always going to be the wrong solution, it's dangerous and very likely to leak into the image which you are deploying. Perhaps you can clone the private images as part of your GitLab build, and then add them into the build? Have you seen the "copy common files" feature? https://docs.openfaas.com/reference/yaml/#copy
Using --build-arg
to inject the data may be a better approach, but be careful to check whether it's cached in the image layers.
For the HTTP proxy, you should be inject this via the --build-arg HTTP_PROXY=
mechanism or using the stack.yml file
/set title: Support request for private registries and HTTP proxies in Node
I totally agree with the argument of leaking into the image. This may be true and hard to cure.
And --build-arg
may be the better solution as well.
Closing here.
Expected Behaviour
When building and deploying functions in a restricted environment (e.g. a corporate environment), additional settings for npm and
npm install
might become necessary to be set, including:Current Behaviour
Currently, it is not possible (or hard, using environment variables for e.g. proxy settings) to specify additional settings for npm.
Possible Solution
The above settings (and more) can be achieved by defining an
.npmrc
file. When the file is present in the working directory, when executingnpm install
, npm will consider the configuration from it.So the proposed solution would be:
.npmrc
file during docker build.npmrc
file to the template and function example to improve UXContext
The problem is valid in any environment that needs custom npm settings, like custom repositories or proxy settings.
Your Environment
Are you using Docker Swarm or Kubernetes (FaaS-netes)? Self-managed k3s, with OpenFaas deployments using GitLab Serverless
Operating System and version (e.g. Linux, Windows, MacOS): Linux