简体   繁体   English

节点链码在代理后面实例化

[英]node chaincode instantiate behind proxy

I'm following the official document: https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html我正在关注官方文件: 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.但是当我实例化节点版本链码时,因为我的机器在代理后面工作,所以 NPM 总是向我抛出网络异常。

I have tried setting proxy in the package.json or scripts, but it does not work.我曾尝试在 package.json 或脚本中设置代理,但它不起作用。

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...它会抛出异常,因为容器没有互联网访问权限来下载节点模块,否则......

I think your best bet is to modify the chaincode docker image used for building to to have npm preconfigured with a proxy via:我认为最好的办法是修改用于构建的链码 docker 映像,以便通过以下方式使用代理预配置 npm:

npm config set proxy http://proxy.company.com:8080 npm 配置集代理http://proxy.company.com:8080

npm config set https-proxy http://proxy.company.com:8080 npm 配置集 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:要修改它,您可以在用于创建构建链代码的 docker 文件的 docker 镜像模板中的上述 npm 命令之前添加“RUN”前缀:

RUN npm config set proxy http://proxy.company.com:8080运行 npm 配置集代理http://proxy.company.com:8080

RUN npm config set https-proxy http://proxy.company.com:8080运行 npm 配置集 https-proxy http://proxy.company.com:8080

At node.js chaincode build time, the following commands are run :在 node.js 链码构建时, 运行以下命令

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM