Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

ibm-functions/runtime-nodejs

Repository files navigation

This repository is no longer maintained.

IBM Cloud Functions reached end of life and this repository is no longer active.

For Apache OpenWhisk visit: https://github.com/apache/openwhisk.


IBM Cloud Functions runtime for nodejs

Build Status

The runtime provides the following npm packages for IBM Cloud:

How to use as a docker Action

To use as a docker action

ibmcloud wsk action update myAction myAction.js --docker ibmfunctions/action-nodejs-ibm-v16

This works on any deployment of Apache OpenWhisk or IBM Cloud Functions

Future: IBM Cloud Functions (based on Apache OpenWhisk)

To use as a nodejs kind action

ibmcloud wsk action update myAction myAction --kind nodejs:16

Tip: Not available yet in the IBM Cloud

Working with the local git repo

Prerequisite: Export OPENWHISK_HOME to point to your incubator/openwhisk cloned directory.

To build the nodejs:16 runtime:

./gradlew nodejs16:distDocker

This will produce the image whisk/action-nodejs-ibm-v16

Build and Push image

docker login
./gradlew nodejs16:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io

Deploy OpenWhisk using ansible environment that adds the new king nodejs:16 Assuming you have OpenWhisk already deploy localy and OPENWHISK_HOME pointing to root directory of OpenWhisk core repository.

Set ROOTDIR to the root directory of this repository.

Redeploy OpenWhisk

cd $OPENWHISK_HOME/ansible
ANSIBLE_CMD="ansible-playbook -i ${ROOTDIR}/ansible/environments/local"
$ANSIBLE_CMD setup.yml
$ANSIBLE_CMD couchdb.yml
$ANSIBLE_CMD initdb.yml
$ANSIBLE_CMD wipe.yml
$ANSIBLE_CMD openwhisk.yml

To use as docker action push to your own dockerhub account

docker tag whisk/action-nodejs-ibm-v16 $user_prefix/action-nodejs-ibm-v16
docker push $user_prefix/action-nodejs-ibm-v16

Then create the action using your the image from dockerhub

wsk action update myAction myAction.js --docker $user_prefix/action-nodejs-ibm-v16

The $user_prefix is usually your dockerhub user id.

Testing

Install dependencies from the root directory on $OPENWHISK_HOME repository

./gradlew install

Using IntelliJ:

  • Import project as gradle project.
  • Make sure working directory is root of the project/repo

Using Gradle

To run all tests: ./gradlew tests:test this include tests depending on credentials

To run all tests except those which do not rely on credentials ./gradlew tests:testWithoutCredentials

To run a single test-class: ./gradlew tests:test --tests <SomeGradleTestFilter>

For example, in order to execute the tests in /tests/src/test/scala/actionContainers/IBMNodeJSActionDB2Tests.scala, run: ./gradlew tests:test --tests *IBMNodeJsActionDB2Tests

Note: If you're running all tests locally with credentials like ./gradlew tests:test or ./gradlew tests:test --tests *CredentialsIBMNodeJsActionWatsonTests you need to set up a tests/credentials.json file containing Watson credentials in the format of:

{
  "language_translation":[
    {
      "credentials": {
        "url": "",
        "apikey": ""
      }
    }
  ],
  "cloudantNoSQLDB":[
    {
      "credentials": {
        "url": "",
        "host": "",
        "port": "" ,
        "password": "",
        "username": ""
      }
    }
  ],
  "dashDB":[
      {
        "credentials": {
          "ssldsn": "DATABASE=BLUDB;HOSTNAME=<hostname_value>;PORT=50001;PROTOCOL=TCPIP;UID=<username_value>;PWD=<password_value>;Security=SSL;"
        }
      }
  ],
  "cloud-object-storage":[
      {
        "credentials": {
          "resource_instance_id": "",
          "apikey": ""
        }
      }
  ],

}

Then update the whisk.properties file located in the directory $OPENWHISK_HOME, using the variable vcap.services.file

Maintenance Tasks

Updating Node.js 16 runtime

  • Get the version of the latest tag ibm image
VERSION=$(git tag | grep 16@ | tail -2 | head -1 | awk -F"@" '{print $2 }')
  • Check the version of nodejs on the latest ibm image released
docker run --rm -it ibmfunctions/action-nodejs-v16:$VERSION sh -c "node -v"
nvm ls-remote | grep v16.

Pushing new versions for runtimes

  • After the PR is merged and the master pass Travis CI, checkout master.
  • Create tag for each runtime and push upstream
git tag 16@<new version>
git push upstream 16@<new version>
  • After the image is deployed to production update the latest tag for each runtime.
git tag 16@latest -f
git push upstream 16@latest -f

License

Apache 2.0

About

⛔️ DEPRECATED - IBM Cloud Functions NodeJS Runtime

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 12

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy