Use Java 8 on Bluemix: How to use a custom buildpack

The default java runtime is the ibm provides liberty profile. Which has very good additional features that increase performance, but is currently (May, 2015) still on Java 7. So when you want to use Java 8 features in your application you just have to deploy a customer build pack which is not more then to a just the manifest.yml file in the root directory of your application. And there you have to change the line with the buildpack: to https://github.com/cloudfoundry/java-buildpack. The result should look something like this.

buildpack bluemix java 8

Setting up your MEAN.js Develeoper Environment with Vagrant, Chef and Berkshelf

First you have to get started developing your Infrastructure Environment. An Up to Date Guide can be found at safaribooksonline.com. The following procedure will get your local workstation configured and ready to develop cookbooks with Test Kitchen, Vagrant and Chef-zero. Note that this is not a tutorial on how to write cookbooks.

This is just a short discription on the progress I made and not complete. Since I switch from the MEAN.js stack to the jHistper Stack (Java (Spring) in the Backend, AngularJS and Bootstrap in the Frontend, and a variety of databases) I won't continue this. Hope this still helps someone.

The Tools

Vagrant – We use Vagrant and Virtualbox to test our cookbook code and run our tests on our local workstations. The creator of Vagrant wrote the definitive guide for us all.

Test Kitchen – Test Kitchen is the tool we use to manage our Vagrant configurations, configure our environment to mirror Production in a meaningful way and run our tests.

Chef-Zero – Chef-Zero is a lightweight local Chef Server that our testing VMs use to mimic our live Chef environment.

ChefDK – The Chef Development Kit provided by Opscode bundles various Chef tools together. The beauty of ChefDK is that it comes with an embedded Ruby environment and the necessary Ruby Gems required by the tools. This is a great improvement if you’ve ever had to deal with pre-ChefDK local Ruby/RVM configurations, fluctuating gem dependancies and breaking changes between tools.

Getting Vagrant, ChefDK and Tools

ChefDK Installation

First, download and install ChefDK from https://downloads.getchef.com/chef-dk. ChefDK comes with chef-client, Berkshelf, Test Kitchen, ChefSpec, Foodcritic and more.

Vagrant Installation and Configuration

Next, install Vagrant. Head over to https://www.vagrantup.com/downloads.html and download and install the appropriate package for your system.

Once you have Vagrant installed you’ll run the following commands in your (bash) shell to install the supporting plug-ins that we need to integrate Vagrant and Chef.

vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-chef-zero
vagrant plugin install vagrant-vbguest

After installing these, you should logout of your shell and relaunch it to pickup the new environment variables.

Virtualbox Installation and Setup

Next, download and install VirtualBox from https://www.virtualbox.org/wiki/Downloads.

Follow the directions for your platform but skip the VMWare portion and go to the Test Your Setup section below if you’ve opted to use Virtualbox.

Alternately, VMWare installation and Setup

(only do this if you use VMWare rather than Virtualbox)

Download and install VMWare from the web site and have your Vagrant VMWare license handy. You need to purchase the Vagrant VMWare integration license from HashiCorp (the company that makes Vagrant).

Copy your Vagrant VMWare license to ~/.vagrant.d/vmware-license.lic then follow the steps for your specific setup:

For VMWare Workstation, add the following to your ~/.bashrc file ( or ~/.bash_profile on OS X):

export VAGRANT_DEFAULT_PROVIDER=vmware_workstation

Then run:

vagrant plugin install vagrant-vmware-workstation
vagrant plugin license vagrant-vmware-workstation ~/.vagrant.d/vmware-license.lic

For VMWare Fusion, add the following to your ~/.bashrc file ( or ~/.bash_profile on OS X):

export VAGRANT_DEFAULT_PROVIDER=vmware_workstation

Then run:

vagrant plugin install vagrant-vmware-workstation
vagrant plugin license vagrant-vmware-workstation ~/.vagrant.d/vmware-license.lic

lly, everyone using VMWare should reboot their machine and launch VMWare for the first time, accepting the license agreement and allowing it to initialize itself once. Do this before running Vagrant. FYI: Vagrant has plans to consolidate Fusion and Workstation at some point in the near future.

Finally, everyone using VMWare should reboot their machine and launch VMWare for the first time, accepting the license agreement and allowing it to initialize itself once. Do this before running Vagrant. FYI: Vagrant has plans to consolidate Fusion and Workstation at some point in the near future.

Prepare Chef Tools

As you work more with Chef, you will eventually run into repositories that depend on Chef recipes that require your a broad range of tools to be available and configured on your workstation. Run through the following steps now so they are available when you need them.

Configure Knife

(do this only if you don’t have a knife configuration already)
Setup Knife and accept the defaults:

knife configure

You must place your validation key in the following location before generating instance data with Knife:

/etc/chef-server/chef-validator.pem

Create .pem File

Create a .pem for Chef Zero to use when faking Chef server for local configuration.

openssl genrsa 2048 > ~/.chef/<username from knife configure>.pem

Test Your New Setup

You should now create a temporary directory locally for Vagrant VMs and then test that you can create a new Vagrant project. There are many GitHub projects with Vagrant file templates. I recommend that you read up on Vagrant and create your own simple configuration file but if you want to test you can use the one in the next step.

Create an empty directory (~/vagrant_vm, say) for the configuration. This location will contain a Vagrantfile and will eventually contain the running VM as well.

you@workstation$ mkdir ~/vagrant_vm
you@workstation$ cd ~/vagrant_vm

Preparing your Vagrantfile

Copy a Vagrant file from a GitHub repo that suits you and put it in a new file called Vagrantfile in the ~/vagrant_vm directory. (You must name the file Vagrantfile. You cannot always leave it the same name as it is in GitHub.) You can find some generic Vagrantfile examples and the ssh key for the images here: https://github.com/patrickdlee/vagrant-examples.

Or you can use the example one below:

#Quick vagrant file for testing
#
Vagrant::Config.run do |config|
  config.vm.box = 'precise32'
  config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
end

Using the Virtual Machine

Next, launch the VM from the ~/vagrant_vm directory using vagrant up:

you@workstation$ vagrant up

There will be lots of output and once the machine has booted you can ssh to it.

you@workstation$ vagrant ssh

Vagrant exports ~/vagrant_vm from your local your local machine to the VM. Check that you see the the Vagrantfile and .vagrant directories in the VM by running:

sbo@linux:~$ ls -la /vagrant
total 16drwxrwxr-x  1 sbo  sbo  4096 Oct 10 16:03 .
drwxr-xr-x 23 root root 4096 Oct 10 16:05 ..
drwxrwxr-x  1 sbo  sbo  4096 Oct 10 13:56 .vagrant
-rw-r--r--  1 sbo  sbo  1150 Oct 10 16:03 Vagrantfile

Exit from the VM

sbo@linux:~$ exit

Source: http://stackengine.com/devops-delight-chef-dk-chef-zero-vagrant/

Authoring a Cookbook

Each of the individual parts is now installed and shown to work. So lets configure a machine using chef. To do this we will:

  • Write a cookbook to install some of our favorite packages that should be on every machine
  • Run Foodcritic

Scaffolding a Cookbook with Berkshelf

Berkshelf is the “package manager” for Chef cookbooks. It is also the standard way to scaffold a cookbook with ChefDK.

Generate a Berksfile in a pre-existing cookbook
$ cd cookbooks
$ berks init .

https://www.youtube.com/watch?v=0sPuAb6nB2o

New Place API by Google #APIEconomy

Google has launched its Places API for Android and opened a beta program for it on iOS today. It will allow developers to add better location pickers to their apps, so users can specify where they are with real place names instead of latitudes and longitudes.

In addition, it also allows users to add new places to Google’s database of more than 100 million locations.

Google’s Places API and associated JavaScript library has been available for Web apps for some time now, but the new APIs will help developers easily add their functionality into native mobile apps.

You can hop over to this Google Developers site to find documentation, code samples and demos for the Android API, or sign up for iOS public beta on this page.

Mobile Design for the Apple Smart Watch – A Todo App

Apple gave Developers the chance to and guidelines to have their app ready for the Apple Watch. This show how Apple wants their Smart Watch App to look like. In this case Todoist developed almost a complete version of their todo app witch follower the apple guidelines:

[blockquote author=”Apple” link=”http://techcrunch.com/2015/02/02/heres-how-a-to-do-app-will-work-on-the-apple-watch/?ncid=rss” style=”” target=”_blank”]The apps themselves should not be very complicated or feature-heavy. Instead, they should focus on conveying the most, and most relevant information possible given the limited screen real estate, and for a to-do app, it makes sense that those limits would result in a lot of nested lists.[/blockquote]

I think this is a good advice and will consider this for my own smart watch apps either for iOS or Android.

Save git password and authentication in terminal

I was very annoyed with jazz.net as I had to type in my username and password every time I pushed or pulled something to the repository. But then on stackoverflow I found the solution for mac:

[code]git config –global credential.helper osxkeychain[/code]

this allows you to use the normal OS X keychain to store the git credentials. In the link you find also windows and linux solutions.

Git clone and push to new repostory

For my mobile application I wanted to start from the ibm sample bluemix application ‘bluelist’ but then store my source code in my own repository at github. For this to do I as follows :  

  1. I create a new repo at github. 
  2. I clone the repo from the ibm repo to my local machine. 
  3. git remote rename origin upstream 
  4. git remote add origin git@github.com:den53/bluelist.git
  5. git push -u origin master

To pull in patches from upstream, I simply run git pull upstream master && git push origin master.

 

Developing a hybrid Mobile Application on Bluemix

In this post I will document how to develop an mobile application on the IBM Bluemix Plattform in under 1 hour.

  1. First you have to set up your mobile development environment especially install npm, cordova, ionic, bower and git (on OSX I suggest using hombrew). [code]npm install -g cordova
    npm install -g ionic
    sudo npm install ios-sim -g
    npm install -g bower[/code]
  2. To understand how hyrids apps with Cordova work you should read up on it (Cordova Getting Started Guide for Android / Cordova Getting Started Guide for IOS).
  3. Clone the app with git to your drive:  [code]git clone https://hub.jazz.net/git/mobilecloud/bluelist-mobiledata[/code]
  4. Create a boilerplate application on IBM Bluemix
  5. Configure the Application for use with Bluemix (www/bluelist.json).
    [code]{ “applicationId”: “INSERT_APPLICATION_ID_HERE”, “applicationSecret”: “INSERT_APPLICATION_SECRET_HERE”, “applicationRoute”: “INSERT_APPLICATION_ROUTE_HERE” }[/code]
  6. Modern mobile web applications are now built using dependency managers. The hybrid application sample uses bower for the client side components. This includes the pulling down of the latest levels of the Mobile Cloud SDKs
    1. From the sample app directory, run [code]bower install[/code]
    2. To check the development runtime, make sure all existing copies of chrome have been shutdown.
    3. Load chrome with web security turned off, this enables the mobile testing to avoid any Cross Origin.
      1. On Mac: [code]open -a Google\ Chrome –args –disable-web-security[/code]
      2. On Windows: [code]start chrome.exe –disable-web-security[/code]
    4. From the app directory, run ionic serve
    5. The hybrid component should now be visible in chrome browser. The ionic tools support live reload, so if you edit the code you can see if refresh in the browser.
    6. The sample app can be accessed using this local url: http://localhost:8100/#/tab/list
  7. You need to make sure you have the latest xcode and android development tools installed on your development environment.
    1. From the sample app directory run the following command to build the sample for iOS: [code]ionic build ios[/code]
    2. To run it in the emulator you can run emulate command.
    3. [code]ionc emulate ios[/code]
    4. You should now see the bluelist-cordova app now running inside the IOS Simulator.

If you want to test with Android make sure you add the android platform to the project.
[code]cordova platform add android[/code]
Do not add the Bluemix Cordova plugin to this project. Dependencies will conflict. If you’d like to use the Cordova Bluemix plugins check out the Dev Works articles for mobile data here and push notifications here.