Build Oracle JET App, Ship & Run on Container Cloud Service (OCCS)

In this post I am going to show how to containarize an Oracle JET application and let it run on Container Cloud Service (OCCS) using the following steps

  • Build Docker image based on nginx and the JET Application
  • Push it on Docker-Hub (Container Registry, could also be https://quay.io/)
  • Create a Service in Oracle Container Cloud Service (OCCS)
  • Deploy Service (the JET Application so to say)

Prerequisites:

Build Docker image for JET Application

Create the following file and save it to the root folder of your JET Application Workspace.

Dockerfile

Next build your JET application by running

> grunt build

> docker build -t enpit/jet-spotify-app .

Check locally (on your machine) if everything served as expected from the container by running

docker run --name enpit-jet-spotify-app -p 8080:80 -d enpit/jet-spotify-app

and opening localhost:8080 (in this case) in your browser to see the result.

Best Practice: Create a build.sh skript for this repetitive tasks or make it part of your npm script. See sample below (For production use the grunt build:release)

package.json: npm scripts

Push it on Docker Hub

First of all create an account on https://hub.docker.com . Then move over to your command line and enter:

docker login

Username: <username>
Password: <password>
Login Succeeded

Now you are ready to push the docker image to the docker registry by typing

docker push enpit/jet-spotify-app
The push refers to a repository [docker.io/enpit/jet-spotify-app]

011b303988d2: Pushed 
latest: digest: …. size: 1365

All done here.

Create a Service in OCCS

Head over the the Oracle Cloud Service Console and choose > Services > New Service (Prerequisite: OCCS Account. From an almost hidden menu item you can open the Service Console. )

In the opened Popup fill in

  • Service Name: enpit jet spotify app
  • Image: enpit/jet-spotify-app
  • Add Ports Configuration: Host Port: 8080 Container Port: 80 tcp
OCCS Console: Service configuration view
OCCS Console: Docker Run View (pretty basic here)

Save your changes.

Deploy Service

Having defined the Service just hit the Deploy button….

OCCS Console: Push the Deploy Button :-)

..and fill in desired configuration

  • Which Resource Pool to use: default, test, production ?
  • Scaling: <Quantity of containers>
  • Scheduling Policy

Press Deploy.

Notice how the docker image is pulled from the registry to OCCS.

Click on the Hostname Link.

Look up the public_ip address.

The sample application is available under <public_ip>:8080 .

Conclusion

The overall delivery of JET Apps using Containers is great. If you are coming from Enterprise IT there is no need for Application Servers for this kind of (client) web application. Nginx (or Apache or node/express) are just fine. The resulting image size in my example is < 90 MB (JET build dev) and < 70 MB (build:release).

I tried the automatic Build Feature of Docker Hub but find it quite useless, because in real world scenarios you need npm, bower etc to build Oracle JET Apps or kind of this. Codeship e.g. has a nice solution for this overall Docker based CI/CD experience.

Further Information