Mobile application developers can now build and deploy applications on Cloud Foundry using the FeedHenry developer platform. This guest post provides another example from the ecosystem of ISVs hosting their applications on Cloud Foundry.
Guest blog post by Mícheál Ó Foghlú.
In the following blog we will demonstrate how to use the FeedHenry Command Line tool to clone a sample/template app, (from GitHub), stage the server-side code to CloudFoundry.com (Node.js and Redis), and build a HTML5 & JS app for an Android device. See http://mobilecf.feedhenry.com for detailed instructions. Also check out the FeedHenry App Studio to preview the app that you create here.
The FeedHenry CLI tool, fhc, uses node.js on your local machine. To setup node.js use the node installer located at http://nodejs.org/#download
Installing or Updating the FeedHenry CLI Tool (fhc)
Use the Node Package Manager (npm) to install or update the FeedHenry CLI tool (fhc).
$ sudo npm install –g fh-fhc
(the optional prefix “sudo” gives permission to install system-wide in a Unix style environment).
To test fhc is installed correctly and see the version you have installed, use:
$ fhc -v
fhc has some built-in documentation; use fhc help for general help, or fhc help [command] for help on a specific command.
Logging in using your CloudFoundry.com credentials
To get started with the CLI tool you need to login to the FeedHenry platform using your CloudFoundry.com credentials. This will automatically create a FeedHenry account at mobilecf.feedhenry.com.
$ fhc target https://mobilecf.feedhenry.com/ $ fhc login
In the next 3 simple steps, we will illustrate how to create a HTML5/JS app with an instant backend in cloudfoundry.com.
Forking a template app in github (code)
To edit/modify the template app, login to github, and fork the app to your personal account.
Get the read-only git identifier for your cloned app.
Now create an app in the FeedHenry platform linked to your fork of the template app in github.
$ fhc apps create App-Anatomy git://github.com/YOUR-ID/App-Anatomy.git
If using a secured repository, please check out the documentation docs.feedhenry.com for generating and uploading public/private keys.
Staging the backend to Cloud Foundry
Staging to Cloud Foundry requires the use of the unique app identifier that can be acquired by listing the active FeedHenry apps.
$ fhc apps
The staging can be done to the debug environment or the live environment. The former hosts the server-side for “debug” apps, and the latter for “release” apps. Separating these allows developers to exercise functionality separately in testing before deploying to production.
$ fhc stage APP-ID --devel
$ fhc stage APP-ID --live
To ensure that the app has indeed staged correctly use the Cloud Foundry CLI tool (vmc).
$ vmc target api.cloudfoundry.com $ vmc login $ vmc apps $ vmc logs APP-ID
We have just staged the cloud code from our forked app. Each app contains three directories: client, cloud, and shared. The client directory is for the client-side HTML5/JS app, the cloud directory is for the server-side Node.js code (this is what has been staged). The shared directory is in both. Check out the documentation for more information on using the shared directory.
Building the Android client
To generate an Android debug build of the app:
$ fhc build app=APP-ID config=debug destination=android version=2.2 download=true
The appropriate files are gathered, bundled and dispatched to the FeedHenry build farm. The resulting binary file, for Android, an .apk file, is returned and can then be downloaded to your desktop. You can preview the app using the FeedHenry studio at mobilecf.feedhenry.com.
Load the app onto the phone by using email or Dropbox
That’s it – you have built and staged an app in 3 easy steps.
Note: Editing the code in the git repository can make changes to the server-side and the client-side functionality. Those changes can be uploaded to FeedHenry via a git pull request. The updated server-side code can be re-staged, and the updated client-side code can be used to build a new version of the app. To find out more about this template app, App-Anatomy, see FH App-Anatomy in the References.
To get started go to http://mobilecf.feedhenry.com
- Installing vmc: http://start.cloudfoundry.com/tools/vmc/installing-vmc.html
- Installing Node.js: http://nodejs.org/#download
- Installing npm: http://npmjs.org/
- Installing fhc: http://docs.feedhenry.com/our-tools-for-developers/fhc-command-line/
- Cloning an app: http://docs.feedhenry.com/training-labs/fhc/creating-an-app-from-github/
- FeedHenry App-Anatomy: http://docs.feedhenry.com/training-labs/app-labs/app-anatomy/
- FeedHenry Android Build: http://docs.feedhenry.com/training-labs/fhc/creating-an-android-debug-build/
- FeedHenry Staging to Cloud Foundry: http://docs.feedhenry.com/training-labs/fhc/creating-an-android-debug-build/#step3
Join us for a Cloud Foundry mobile meetup, March 25th, San Francisco.
Signup for Cloud Foundry today, and start building your own mobile app!
About the Author
BiographyMore Content by Cloud Foundry