node chaincode instantiate behind proxy

妖精的绣舞 提交于 2020-07-07 23:01:53

问题


I'm following the official document: https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html

I am building my first network. But when I instantiate the node version chaincode, because my machine is working behind the proxy, NPM always throws network exception to me.

I have tried setting proxy in the package.json or scripts, but it does not work.

How can I avoid this?

For example, if I execute:

./byfn.sh -c mychannel -l go up

it works well.

But, if I execute:

./byfn.sh -c mychannel -l node up

It would throw an exception because the container doesn't have the internet access to download the node module or else...


回答1:


I think your best bet is to modify the chaincode docker image used for building to to have npm preconfigured with a proxy via:

npm config set proxy http://proxy.company.com:8080

npm config set https-proxy http://proxy.company.com:8080

To modify it, you can just prefix "RUN" before the npm commands above in the docker image template that is used to create the docker file in which the chaincode is built:

RUN npm config set proxy http://proxy.company.com:8080

RUN npm config set https-proxy http://proxy.company.com:8080

At node.js chaincode build time, the following commands are run:

cp -R /chaincode/input/src/. /chaincode/output && cd /chaincode/output && npm install --production


来源:https://stackoverflow.com/questions/52354240/node-chaincode-instantiate-behind-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!