You are giving this presentation and as attendees leave the room you'd like to get a quick feel about how you did. Emoting mimics the smiley terminals you may see at the airport security or whenever you are queueing somewhere.
Built using the IBM Bluemix, the application uses:
- IBM Bluemix OpenWhisk to host the backend
- Cloudant to persist the data
- GitHub Pages to host the frontend
No runtime to deploy, no server to manage :)
architecture digraph G { node [fontname = "helvetica"]; rankdir=LR; user -> github; github -> openwhisk [label="API Calls"]; openwhisk -> cloudant; github [shape=circle style=filled color="%234E96DB" fontcolor=white label="GitHub Pages"]; openwhisk [shape=circle style=filled color="%2324B643" fontcolor=white label="OpenWhisk"]; cloudant [shape=circle style=filled color="%234E96DB" fontcolor=white label="Cloudant"]; } architecture
- IBM Bluemix account. Sign up for Bluemix, or use an existing account.
OpenWhisk Emoting comes with a toolchain you can use to deploy the solution with few clicks. If you want to deploy it manually, you can skip this section.
-
Ensure your organization has enough quota for one service.
-
Click Deploy to Bluemix to start the Bluemix DevOps wizard:
-
Select the GitHub box.
-
Decide whether you want to fork/clone the OpenWhisk Emoting repository.
-
If you decide to Clone, set a name for your GitHub repository.
-
Select the Delivery Pipeline box.
-
Select the organization and space where you want to deploy the app. Keep US South for the region as OpenWhisk is only available there today.
⚠️ Make sure the organization and the space have no space in their names. -
Click Create.
-
Select the Delivery Pipeline named openwhisk-emoting.
-
Wait for the Deploy job to complete.
-
When the job complete, look at its log and make note of the API Gateway endpoint where the OpenWhisk API has been deployed. You should see log statements like:
ok: created API /emoting/1/questions PUT for action /_/emoting/questionCreate https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/abcdeff9d9300320200dhcdbcddc/emoting/1/questions ok: created API /emoting/1/questions GET for action /_/emoting/questionRead https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/abcdeff9d9300320200dhcdbcddc/emoting/1/questions ok: created API /emoting/1/stats GET for action /_/emoting/questionStats https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/abcdeff9d9300320200dhcdbcddc/emoting/1/stats ok: created API /emoting/1/ratings PUT for action /_/emoting/ratingCreate https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/abcdeff9d9300320200dhcdbcddc/emoting/1/ratings
https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/abcdeff9d9300320200dhcdbcddc/emoting/1 is the API Gateway endpoint in this example.
-
Checkout the code from your own openwhisk-emoting repository.
-
Edit
docs/js/emoting.js
and change theapiUrl
value to your API base path. -
Commit the
docs/js/emoting.js
file. -
Enable GitHub Pages on your repo. When doing so, select the option to use the
docs
folder in the master branch.
-
Clone or fork the repository https://github.com/IBM-Cloud/openwhisk-emoting
-
Checkout the code
-
Ensure your OpenWhisk command line interface is property configured with:
wsk list
This shows the packages, actions, triggers and rules currently deployed in your OpenWhisk namespace.
-
Create a Cloudant service in IBM Bluemix
-
Copy the file named template-local.env into local.env
cp template-local.env local.env
-
Get the Cloudant service credentials from the Bluemix dashbaord and replace placeholders in
local.env
with corresponding values (url, username and password). These properties will be injected into a package so that all actions can get access to the database. -
Deploy the actions to OpenWhisk
./deploy.sh --install
-
Expose the OpenWhisk actions as REST endpoints
./deploy.sh --installApi
You may need to use
wsk bluemix login
so that thewsk
command line can create the API in Bluemix. -
Make note of your API Gateway base path in the output. The base path looks like
https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/abcdeff9d9300320200dhcdbcddc/emoting/1
. -
Edit
docs/js/emoting.js
and change theapiUrl
value to your API base path. -
Commit the
docs/js/emoting.js
file. -
Enable GitHub Pages on your repo. When doing so, select the option to use the
docs
folder in the master branch.
-
Follow the previous steps to deploy the OpenWhisk actions.
-
Make sure to edit
docs/js/emoting.js
-
Install dependencies
npm install
-
Start the local web server
npm start
-
Point your browser to http://127.0.0.1:8080
File | Description |
---|---|
question.create.js | Creates a new question. |
question.read.js | Returns the text of a question based on its ID. |
question.stats.js | Returns results about a given question. |
rating.create.js | Called when a user taps on one of the rating. |
deploy.sh | Helper script to install, uninstall, update the OpenWhisk actions used by the application. |
See License.txt for license information.
This project is a sample application created for the purpose of demonstrating a serverless app with OpenWhisk. The program is provided as-is with no warranties of any kind, express or implied.