While some developers prefer command line tools, I often use graphical tools if available since I cannot memorize all the different commands. That's why I tried the relative new Docker Tooling for Eclipse. The plugin is relative new and there is certainly room for improvements but it helps with managing images and containers, e.g. running containers and creating images. Below is a simple sample how to use the tooling to create a Liberty based image with a hello world app that can be deployed to Bluemix.

Since the end of last year the Liberty profile is on Docker Hub. The Liberty Profile image is supplied for IBM Containers. You can use this image to build your application Java-based war files in a Liberty container.

The hello world sample contains one html file on the context root "/".

There is also a servlet on the path "Servlet".

The context root "/" is defined in ibm-web-ext.xml.

The sample uses Maven to build the project and create a war file.

The Maven install can be triggered from the Eclipse IDE.

The following Dockerfile is a very simple sample. Read the documentation for more options.

Via the Docker Tooling you can refer to the Dockerfile to create a new image.

Based on the image you can run containers. In the sample I used all defaults, e.g. the port mappings.

To find out the URL to invoke your deployed app on Docker open the ports section. The needs to be replaced with your Docker ip address. You can find it out via "boot2docker ip". Since I don't want to do this over and over I created an entry in my host file for "dockerhost". To run the sample app with the context root "/" simply invoke "http://dockerhost:yourport".

Similarly to the dependency managers mvn, npm, cocoapods, etc. Bower is a nice dependency manager for web resources to pull down JavaScript, CSS and other files. This makes it easy for developers to find and install certain libraries. Plus the same functionality can be integrated in the build process.

Using Bower as part of a build might make sense if, for example, you want to get latest versions of libraries with security fixes automatically. If you want to open source code, it might also make it easier for you to only refer and not include third party libraries dependent on your corporate open source policies.

I've found a nice Maven plugin to run Bower as part of a build and it works nicely, both locally as well as on Bluemix DevOps - frontend maven plugin. The plugin installs Node and npm and then Bower.

To define the web resources you want to download a bower.json file is used. With a .bowerrc file Bower can be configured, e.g. the target path for the web resources.

The installation of the Maven plugin is simple and well documented. Essentially you need to define the plugin in the pom.xml and you need a package.json file.

Here is how my sample Java project looks like before building it.

After a mvn build the web resources have been downloaded to the WebContent directory.

You don't have to do anything else to use the same functionality on Bluemix DevOps. Just make sure you add the new files and folders to your .gitignore.

Accessing On-Premises Data from XPages Applications on Bluemix

By Niklas Heidloff, posted on Jul 20, 2015

When building new applications on the cloud, enterprises often need to access existing data that resides on-premises. Below is a high level description how to access data in on-premises XPages NoSQL databases from XPages applications running on IBM Bluemix.

The sample below shows how to invoke the database REST APIs (IBM Domino Access Services) from an XPages application. As an example database I used Collaboration Today that I deployed on my on-premises Domino server. The only change I had to do in this database was to enable the REST APIs in the application and view properties (see documentation).

In a new database (xpagesrestclient.nsf) I added a simple home.xsp and defined a managed bean.

The managed bean uses the Fluent API to invoke the REST APIs. I had to write a simple JSON parser to generate the list of news entry objects since the XPages Bluemix runtime currently doesn't allow Java reflection.

The key component to make all of this work is the Secure Gateway service. To find out more read this blog and the blogs from Mark Roden.

Note that in this demo I only use basic authentication and the connection from the cloud to on-premises is not encrypted. You certainly should not do this for production apps.

Here is a screenshot of the result.

Bluemix Selfie Drone now available as Open Source

By Niklas Heidloff, posted on Jul 16, 2015

The Bluemix Selfie Drone is now available as open source. Get the code from GitHub.

The project contains an application to take selfies via a Parrot AR Drone 2.0. Via navigation buttons in a web application the drone can be steered and a series of pictures can be taken. The pictures are stored for later review. Additionally faces on the pictures are recognized and portraits are cropped out which can be tweeted. Check out the screenshot of the web application.

The application has been implemented via IBM Bluemix and the Internet of Things service. The pictures are stored in a Cloudant NoSQL database. The Alchemy Face Recognition API is used to find the faces. The web application has been built via Java and the Liberty for Java runtime.

To run the application you also need to set up the Parrot drone controller which is a Node.js application running on your notebook. This application uses the node-ar-drone module, an implementation of the Parrot networking protocols, to communicate with the drone. To find out more about the app dev capabilities of the Parrat drones check out Parrot For Developers. To find out more about the controller check out the video from Ryan Baxter.

Bluemix made the implementation of the application pretty easy. I used the IoT service because it manages the secure/reliable communications and provides a free tier up to 10 devices for testing. The service has the ability to create organizations, register devices and applications and ensure only applications that are registered to the organization can communicate to the device end points.

I used the AlchemyVision Face API to identify faces on the pictures. There is a simple REST API that you can try online. The API also returns the gender and age of the recognized people which I didn't use in this application. It even recognizes specific people from a corpus of 60,000 well known people.

I chose the Cloudant NoSQL database because it's really easy to store the pictures as attachments. It's also easy to create a database and the design programmatically the first time the application code accesses the database. Plus for development purposes developers can use the database service for free as long as they use less than 20GB of data and less than 100,000 API calls per month.

As runtime I picked Liberty for Java but I also could have used other runtimes like Node.js. I decided to use Java simply because personally I have most experience in Java and I didn't see a compelling reason to use another technology. There is also a good sample how to use web sockets which I needed to display the pictures and there are also many other samples and tutorials I could leverage. I did the frontend via AngularJS which invokes REST APIs implemented in the Java application.
For some people this is old news, but I just used for the first time the Cloud Foundry Maven Plugin to build and deploy a Bluemix application and it made the deployment really easy. Below are some of the key concepts I used.

I built a Java application that leverages the AlchemyAPI service which at this point requires to go to a separate website and register an API key which is then stored in a user provided service. Additionally I used web sockets and I had to set an environment variable to use this feature on Liberty for Java.

With the Cloud Foundry Maven Plugin I can create user provided services, normal services, set environment variables and much more. The pom.xml screenshot below shows the configuration of the plugin. To use the plugin you simply add it to your pom.xml.

In order to invoke the build and deployment task you can execute the following command and pass in input parameters.

For the actual deployment to Bluemix the plugin requires your Bluemix credentials which are stored in a Settings.xml file in ~/.m2.

Update July 17th: You should use a profile as documented by Ryan below. Here is a sample.

More Blog Entries ...

Hi, my name is Niklas Heidloff. I work for IBM as an IBM Bluemix Developer Advocate. The blog contains information about IBM Bluemix and articles about my previous work in IBM Collaboration Solutions, esp. IBM Connections and XPages.



The postings on this site are my own and don't necessarily represent my employer IBM's positions, strategies or opinions.