IBM MobileFirst Platform Foundation version 7.1 adds support for running the platform in a container on the cloud in IBM Bluemix. The idea is that anyone should be able to spin up a MobileFirst server in the cloud, deploy applications and adapters to it and reconfigure mobile apps to use it quickly and easily. I thought I would give it a try with my Internet of Things Doorbell app and see how easy it really is.
Here is the architecture of my doorbell system. The only parts that should be affected are the MobileFirst Platform Foundation (MFP) server component and the native iOS Mobile App itself.
MobileFirst 7.1 provides two options for moving to containers: the prebuilt Getting Started Image and the ability to roll your own image based with Evaluation on Containers.
The Getting Started Image is really meant for kicking the tires and evaluating MFP on Bluemix. It is not at all intended for production. The server, data proxy, analytics server, database and a sample application are all crammed into one container. You also cannot make any runtime changes such as renaming the prebuilt runtime, adding more runtimes or customizing the runtime such as adding back-end code, SSL certificates, etc. The up-side is that you should be able to deploy the prebuilt image very quickly and easily add your own adapter and application.
The Evaluation on Containers is meant for building production deployments. Why it is called “Evaluation” when Getting Started is really for evaluations is a mystery to me. At any rate, Evaluation on Containers is not a prebuilt container. It is actually a “package” of artifacts you use to build your own custom container in Docker. You build the container locally on your machine then push it up to Bluemix Containers to run it.
For today’s experiment, I’m going to use the prebuilt Getting Started Image.
Create the MFP container
Creating the container is similar to creating an application on Bluemix.
- Log into Bluemix at https://ibm.biz/IBM-Bluemix. If you don’t yet have a Bluemix ID, get one for free by clicking the SIGN UP link in the upper right corner of the landing page.
- From the Dashboard, click START CONTAINERS.
- On the next page, there will be a list of all the available prebuilt container images. Click ibm-mobilefirst-starter. This is the Getting Started Image.
- This brings up the creation page for the container. There are a few things that need to be configured on this page which may not be obvious but are very important.
- Provide a Container name. This can be whatever you want but must be unique within your “space”.
- Select the Size of the container. The Knowledge Center recommends at least the “Small” configuration.
- The Public IP address field defaults to Leave Unassigned. You definitely don’t want that. The container will need a public IP so that the iOS app can connect to it. If a public IP has already been allocated to the account, select it here. If not, select Request and Bind Public IP.
- Finally, assign the Public ports that will be opened. It is required that ports 80, 9080 and 443 be opened. This field is a little confusing. The port numbers must be entered separated by commas. The placeholder example shows them also separated by spaces but the field actually does not allow spaces. Enter 80,9080,443.
- Click Create to deploy the container. After only a few seconds, “Your container is running” will appear on the container’s overview page. Note the public IP address that was bound to the container. This is how users and apps will get access to it.
Register with the Container
The admin user that will be used to access the container requires a password. This is the opportunity to define it. Please be more creative with your password than “admin”. Anyone that knows the public IP address of the container will be able to get to this page and gain access to the Operations Console if they guess the password.
- Open a browser tab to the Public IP address. (i.e. http://134168.6.227, in my case). The first time this URL is opened, the container registration page will be shown. Enter a password here for the admin username.
- Click Register.
- After a few seconds, the MobileFirst Operations Console will appear. There is one existing runtime, MobileFirstStarter, which contains three applications and three adapters. These support the WishList sample application.
Accessing sample code, Operations Console and Analytics
The next time the container’s Public IP address is opened, a landing page will be shown that enables you to download the WishList sample application code, open the Operations Console to manage your applications, open the Analytics Console to view analytics and data about your apps and download server logs for troubleshooting.
Update the MobileFirst project
Some modifications to the settings in the MobileFirst project containing the application and adapters are necessary to prepare the artifacts for deployment to the new runtime. I have a MobileFirst project called DoorbellIOSNative that contains the CloudantAdapter adapter and an AIOiOS SDK app. In my case, the adapter is completely portable and will require no changes to run it on a new rutime. I will, however, need to modify the SDK app’s worklight.plist file to point to my new host/port and the name of the new runtime.
- Open the DoorbellIOSNative/apps/APIiOS/worklight.plist file in an editor.
- Replace the host value with the Public IP of the container.
- Replace the port value with 9080.
- Replace the wlServeContext value with “/MobileFirstStarter/”
- Rebuild the project and prepare it for deployment. From the MFP command line tool, use the command ‘
mfp push‘. From MFP Studio in Eclipse, Run As > Run on MobileFirst Development Server.
Deploy the adapter and application to the container
Now the application and adapter need to be deployed to the MobileFirst runtime running in the container on Bluemix.
- Open the MobileFirst Operations Console (http://<your-public-ip>:9080/worklightconsole).
- Click Add new app or adapter. Select the CloudantAdapter.adapter file in the bin directory of your MobileFirst project.
- Repeat the process for the APIiOS-iOSnative-1.0.wlapp application file.
Update the native iOS application
The application itself needs to be updated so that it will look in the right place for the MFP server.
- Open the Xcode project.
- Update the references
- If the worklight.plist and WorklightAPI artifacts were added to the project by NOT checking “Copy items if needed”, then there is nothing else to do before rebuilding. The artifacts in Xcode are links to the actual artifacts that were already updated.
- If copies of these artifacts were made, delete them now. Drag-n-drop the new worklight.plist and WorklightAPI artifacts onto the Xcode Project Navigator to add them.
- Build and run the app on a device. The application is now hosted on an MFP server in the cloud!
Again to be clear, the Getting Started Image is not intended for production workloads. I’ll take a look at building a custom container that can be used for production in a future post. But the Getting Started Image did enable me to deploy my existing app to a functional MFP server running in the cloud on IBM Bluemix in about 10 or 15 minutes. When you compare that with the thought of standing up a server, installing MFP Server, creating a runtime, deploying the adapter, deploying the application and configuring the client app, it’s pretty compelling.