节点链代码在代理后面实例化 [英] node chaincode instantiate behind proxy

查看:76
本文介绍了节点链代码在代理后面实例化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注官方文档: https://hyperledger-fabric .readthedocs.io/en/latest/build_network.html

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

我正在建立我的第一个网络.但是当我实例化节点版本链代码时,由于我的机器在代理后面工作,因此NPM总是向我抛出网络异常.

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.

我尝试在package.json或脚本中设置代理,但是它不起作用.

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

如何避免这种情况?

例如,如果我执行:

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

效果很好.

但是,如果我执行:

./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:

npm配置设置代理 http://proxy.company.com:8080

npm配置设置https-proxy http://proxy.company.com:8080

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

要对其进行修改,您只需在其前面加上"RUN"前缀即可在 docker图像模板用于创建构建链码的docker文件:

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:

运行npm配置设置代理 http://proxy.company.com:8080

运行npm配置设置https-proxy http://proxy.company.com:8080

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

在node.js链代码构建时,

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

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

这篇关于节点链代码在代理后面实例化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆