Update REST Proxy Settings for Running Chaincodes

If you're using Node.js or Java chaincodes which are dependent on external libraries, a few proxy settings must be updated.

You must complete these steps before you instantiate the chaincode. See Instantiate a Chaincode.

Node.js Chaincode

When your Node.js chaincode is instantiated, npm is used to install all dependency libraries from the internet, so in an Oracle Blockchain Platform instance, if there is such a dependancy, you need to ensure the bcs/fabric-ccenv image has internet access.

Set the HTTP proxy for the bcs/fabric-ccenv image following these steps:

  1. Create a Docker file in any location in your VM with the following content (where http://hostname:port is your HTTP proxy access entry):
    FROM bcs/fabric-ccenv:latest
    ENV npm_config_proxy http://hostname:port
  2. Build the image again:
    docker build -f Dockerfile -t bcs/fabric-ccenv:latest

Java Chaincode

To configure the proxy to run Java chaincode:
  1. Gradle-only: Create gradle.properties in a local directory, and add the following content in it:
    systemProp.http.proxyHost=[proxy host]
    systemProp.http.proxyPort=[proxy port]
    systemProp.https.proxyHost=[proxy host]
    systemProp.https.proxyPort=[proxy port]
  2. Maven-only: Create settings.xml in a local directory, and add the following content in it:
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
    https://maven.apache.org/xsd/settings-1.0.0.xsd"> 
    <localRepository/>
    <interactiveMode/> 
    <usePluginRegistry/> 
    <offline/> 
    <pluginGroups/>
    <servers/> 
    <mirrors/> 
    <proxies> 
    <proxy> 
    <id>httpproxy</id>
    <active>true</active> 
    <protocol>http</protocol> 
    <host>[proxy host]</host> 
    <port>[proxy port]</port> 
    </proxy>
    <proxy> 
    <id>httpsproxy</id> 
    <active>true</active> 
    <protocol>https</protocol> 
    <host>[proxy host]</host> 
    <port>[proxy port]</port> 
    </proxy> 
    </proxies> 
    <profiles/> 
    <activeProfiles/>
    </settings>
  3. Create a Docker file and add the following to it:
    FROM bcs/fabric-javaenv:latest
    COPY gradle.properties /root/.gradle/
    COPY settings.xml /root/.m2/
  4. Create a new image:
    docker build -f dockerfile -t bcs/fabric-javaenv:latest