Option 1: Local Setup of the Web Application

In the easiest case the game can be set up on a local machine in less than five minutes. In this case only the game web application is run without being able to register users and having highscores. To set up the game locally, invoke the following commands:

Option 2: Deployment to the IBM Cloud

The application can be deployed to the IBM Cloud in two different ways.

Cloud Foundry Public Application

Serverless application via Cloud Functions and Object Storage

Users and Highscores

In both cases the users API and highscores APIs are optional. If these two components have been set up, the two endpoints are needed.

In local.env define 'API_USERS' and 'API_SCORES'. After this run the following command:

$ scripts/game-configure-apis.sh

Tweets

In order to tweet a picture of the results, additional components need to be set up.

Run the following command to create a new Cloudant service instance. Note that the IBM Cloud lite account only allows one instance. If you have already an instance, define 'CLOUDANT_USERNAME' and 'CLOUDANT_PASSWORD' in local.env.

$ scripts/twitter-setup-cloudant-service.sh

To create the database, run the following command:

$ scripts/twitter-setup-cloudant-database.sh

To create the two OpenWhisk functions and two APIs, run the following command:

$ scripts/twitter-deploy-functions.sh

Option 2a: Deployment to Cloud Foundry

To deploy the web application to Cloud Foundry (as public application), invoke the following command:

Option 2b: Deployment as Serverless Application

The application can also be deployed as serverless application. The static file resources are stored on IBM Cloud Object Storage.

Note: The IBM Cloud lite plan only allows one Object Storage instance in your organization. If you have already an instance, enter the variable 'COS_ID' in local.env which you can get by invoking the following command:

$ ibmcloud resource service-instance object-storage-emotions

In order to create a new instance, run the following command:

$ scripts/object-storage-create-service.sh

There are two options to deploy the web application as serverless application which have pros and cons.

Option 2b2: Cloud Object Storage and Custom Domain

Another advantage is that you can open pages like 'https://xxx/start' directly and page reloads work too.

Unfortunately we haven't managed yet to configure CORS for Cloud Object Storage when loading the models. As a result the application will throw CORS errors in the developer console and the levels cannot be played. As a temporary workaround you can install the Chrome CORS extension Allow-Control-Allow-Origin: *.

In order to create a new bucket, run the following command:

$ scripts/object-storage-create-bucket-domain.sh

In order to upload the files, run the following command:

$ scripts/object-storage-upload-files-domain.sh

In order to use a custom domain, IBM Cloud Functions are used. Run the following command to set everything up: