Build Oracle JET App, Ship & Run on Container Cloud Service (OCCS)
- 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)
- You have docker installed on your development machine . Info: I have done this on macOS 10.12.2 and docker 1.12.3
- You have at least a trial account for https://cloud.oracle.com/container and got a first impression by yourself or from my previous post.
- Sample: For this demo I am using the following JET Application https://github.com/enpit/jet-spotify-explorer
Build Docker image for JET Application
Create the following file and save it to the root folder of your JET Application Workspace.
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)
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:
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]
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
Save your changes.
Having defined the Service just hit the Deploy button….
..and fill in desired configuration
- Which Resource Pool to use: default, test, production ?
- Scaling: <Quantity of containers>
- Scheduling Policy
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 .
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.