This sample, based on the public boilerplate for Cloud Foundry, shows how to build a Node.js application that uses IBM Cloud Cloudant NoSQL DB service instance and deploy it on a IBM Cloud Kubernetes cluster.
The application is very simple: it helps users organize their favorite files.
The UI, written in HTML and jQuery, interacts to a RESTful Express CRUD backend API.
- Install Node.js (Boron version) using nvm (or its version for Windows)
- Once you've cloned this repository,
cd
into this project's root directory - You could work with Cloudant as Docker container or IBM Cloud service instance
- In the first case, you have to issue those commands:
docker run -d --privileged --volume cloudant:/srv --name cloudant --hostname cloudant.dev -p 8080:80 ibmcom/cloudant-developer:latest docker exec -ti cloudant cast license --silent docker exec cloudant cast database init -v -y -p pass curl -s -X 'PUT' http://admin:pass@localhost:8080/my_sample_db
- In the second case, you have to create an free instance of Cloudant NoSQL on IBM Cloud via UI or via CLI, create a set of credentials then copy the URL from credentials and put in
config/configuration-local.json
file undercloudant.credentials.url
path
- Run
npm install
to install the app's dependencies - Set
NODE_ENV
environment variable todevelopment
- Run
npm start
to start the app - Access the running app in a browser at http://localhost:3000
For each changes you'll perform, set NODE_ENV
environment variable to test
run npm test
and eventually add more test cases.
To build a new Docker image and deploy the application on IBM Cloud Kubernetes cluster, you have to issue the following command:
sh ./scripts/build-and-deploy-all.sh