Deploying an Oracle JET application to Application Container Cloud and running on Node.js image 138

Deploying an Oracle JET application to Application Container Cloud and running on Node.js

An article from the Oracle A-Team (http://www.ateam-oracle.com/oracle-jet-with-nodejs/) describes how to run a sample Oracle JET application on a Node.js server. I have followed the steps in that article, ran the JET application locally and then configured the application for deployment to the Oracle Application Container Cloud. Subsequently, I created a new application on that cloud based on the application archive for the JET application and accessed the application. This article briefly describes the steps I went through. It should make clear how to get JET applications to run on the Oracle Application Container Cloud.

Edit April 9th 2016: starting with release 2.0 of Oracle JET, there are some small changes – simplifications – in the steps described below

image

The steps in short are:

  • install Node.js – which includes npm, the Node Package manager
  • install express using npm
  • install express-generator using npm
  • generate the oraclejetwithnodejs application scaffold using express
  • add dependencies using npm
  • try out the scaffold Express application on your local Node.js
  • download the Oracle JET Starter Template Quickstart sample application ZIP file and extract the contents into the oraclejetwithnodejs application directory structure
  • run the application locally to verify it is working correctly
  • create file manifest.json that is required by the Application Container Cloud
  • create an application archive (zip file) for the entire oraclejetwithnodejs application
  • created a new application on the Application Container Cloud based on that application archive for the JET application
  • access the application from any browser anywhere in the world

It turns out that the steps that are really specific for the Application Container Cloud are minuscule: the last four bullets in this list. It is extremely simple, in short, to run an Oracle JET application on Node.js and subsequently in a Node.js container in the Application Container Cloud.

Prepare for a new Node.js Environment and a fresh Application

(this article was originally based on the article from the Oracle A-Team (http://www.ateam-oracle.com/oracle-jet-with-nodejs/); with release 2.0 of Oracle JET, there have been some changes that make this article less relevant).

These are the preparatory steps:

  • install Node.js – which includes npm, the Node Package manager; in my case I downloaded Node.js for Windows from the Home of Node.js. Probably even easier would have been to work with a Docker Container image with a Node.js environment set up.
  • install express using npm (npm install express –save)
  • install express-generator using npm (npm install express-generator -g)
  • generate the oraclejetwithnodejs application scaffold using express (express oraclejetwithnodejs)
  • add dependencies using npm (npm install)

At this point, a directory structure has been created with the basic scaffolding for the new Node.js application, called oraclejetwithnodejs. Nothing has been done that is specific to Oracle JET.

The application – while still bare – can already be run. On Windows, the following command will run Node.js, execute app.js in the application and start listening on local port 3000:

SET DEBUG=oraclejetwithnodejs:* & npm start

(alternatively just node ./bin/www).

Add the Oracle JET Sample application

The Oracle JET Starter Template Quickstart sample application is a client side web application (HTML, JavaScript, CSS and images). It is added to the Node.js application structure mainly as a set of static files that Node.js will serve to the browser requesting these files. The actual JET related work all happens in the browser. It can be a bit confusing to have two kinds of JavaScript files: those that are executed by Node.js and those that are served by Node.js to the browser and that run inside the browser, far away from Node.js.

First, download the Oracle JET Starter Template Quickstart sample application ZIP file from OTN: http://www.oracle.com/technetwork/developer-tools/jet/downloads/index.html and download Quickstart: Basic Starter Template with Oracle JavaScript Extension Toolkit Pre-configured (http://download.oracle.com/otn/JET/20/OracleJET_QuickStartBasic.zip).

OTN Jet Download

Extract the contents into the oraclejetwithnodejs application directory structure, under the public folder in the application scaffold structure.

Here is an overview of the contents of the ZIP file:

image

Stop the Node.js server if it is still running and start the application locally to verify it is working correctly:

SET DEBUG=oraclejetwithnodejs:* & npm start

image

Feel free to browse the Oracle JET application a little. The pivotal file – the starting point for the application – is index.html in directory public. That file is served to the browser when the request comes in to this application at port 3000.

Prepare the Application for the Application Container Cloud

Not much is needed to prepare this application for deployment on Application Container Cloud (also see this article for an introduction into Node.js application on Application Container Cloud).

We need to create a file called manifest.json that is required by the Application Container Cloud. This file specifies name, version details, a description and most importantly: the operating system command to execute in order to launch the application:

{
"runtime":{
"majorVersion":"0.12"
},
"command": "node ./bin/www",
"release": {},
"notes": "Sample, Quick Start Oracle JET Application prepared to run on Oracle Application Container Cloud"
}

Application Container Cloud also needs the package.json file with Node.js dependencies; this file was created at the time of generating the scaffold application.

Create an application archive (zip file) for the entire oraclejetwithnodejs application.

image

 

Create new Application in Application Container Cloud

From the dashboard of the Application Container Cloud, click on Create Application and choose Node.js application. Provide a name and some details and elect to upload the application archive.

image

Press Create.

The application is uploaded. Then the creation (provisioning) will take place.

After a little while, the application [container] is provisioned and the application is deployed and ready for action:

image

Click on the hyperlink to access the application’s main entry point:

 

image

And here we have the Oracle JET sample application, running from the Oracle Application Container Cloud. By doing just a few small things (add manifest.json with proper start command, create overall application archive, create application on Application Container Cloud  based on archive) – we managed to pull this off.

 

Resources

Download the Oracle JET application, configured for deployment on Application Container Cloud: oraclejetwithnodejs.zip (NOTE: the folder public\js\libs in this zip-file is empty; you need to add the libraries here that Oracle JET makes use of – in my case 37 MB worth of JavaScript libraries).

Oracle JET Home Page

Download Oracle JET Quick Start application from OTN

An article from the Oracle A-Team on how to run a sample Oracle JET application on a Node.js server: http://www.ateam-oracle.com/oracle-jet-with-nodejs/

2 Comments

  1. Chris August 25, 2017
    • Lucas Jellema August 28, 2017