Friday, December 23, 2016

Starting again on a Mac

I've been using a Mac for a month or more, but mainly for non-coding work. I still have a small number of windows servers set up in the cloud somewhere that host all my eclipse based tools and heavyweight java runtimes.

I took a train from Pittsburgh to NYC yesterday. 9 hours gave me time to digest a most of Azat Mardan's Practical Node.js book.  Also downloaded Kyle Simpson's excellent "You Don't Know JS" series.

So this afternoon I was just getting started setting up for dev on a Mac. Installed Sublime Text. Installed git, node.js and npm. Installed node-red. Went up to Bluemix and downloaded the bluemix and CF command line tools. Did a git push of projects from my old Windows box, and cloned the ones that made sense do my Mac.

I have a couple goals. 1) Build a UI for my HL7 project and then use API Connect to define and manage the connections to the other parts of that project. 2) Start to investigate replacing BPM UI's with REST based UI's built with some best of breed tooling. 3) Reorganize the Sumo project.

--
JQuery and JQuery UI

Thursday, October 6, 2016

Getting to Docker and IBM Containers on Bluemix

Getting to Docker and then IBM Containers on Bluemix
Just brief notes so I can do it a second time. Posted here for you.

Create an account on Docker Hub.
 https://hub.docker.com
 Read up on docker while you're there.

You need Linux.  Although you can do a lot of this on Windows/Mac I guess too.
 In hindsight - I only needed linux because I was building a linux app that I then moved into a docker image.
 If you don't have linux download VirutalBox and install it.
 Then download the ubuntu iso file. http://www.ubuntu.com/download/desktop

Create an ubuntu image on VirtualBox
 - New.. type=Linux, Version=Unbuntu
 - I had to drop into expert mode and set my disk size to 10GB. The Guest Additions (see below) take up space, but they're useful.
 - Maybe set memory to 3GB
 - it will ask you the location of your ubuntu.iso file.
 - When Ubuntu starts click on the devices menu, and install guest additions. This is what makes shared clipboard work.
 later on...
  - In VirtualBox settings/general/advanced set share to clipboard = bidirectional
  - in VirtualBox settings/network maybe set to bridged adapter if you plan on hitting a docker webservice from your host machine.

In Ubuntu
 open a commmand window (CTRL ALT T)
 curl -fsSL https://get.docker.com | sh
 sudo usermod -aG docker <username>
 logout and then login again

 At this point you can follow the excellent docker tutorials on docker.com
 They will talk you through building a Docker image.
 The mistake I made when I built mine was in the FROM clause in the Dockerfile. BlueMix only supports certain OSs. I had Alpine:3.4 in my FROM clause. I changed it to Ubuntu:16.04 and my project sprang to life on Bluemix.  Knowing this will keep you out of trouble if your goal is to push to Bluemix. Docker itself has more options than bluemix in this regard.
 
 After reading up and creating your Dockerfile
 docker build -t <mynamespace/myappname> .  <-- this will build your docker image. DO NOT MISS the period at the end
 docker run -P <mynamespace/myappname>      <-- the -P tells it to open ports that you've EXPOSE'd in your Dockerfile config

Push to docker hub and share
 docker login  <-- gets you to your docker hub
 docker push <mynamespace/myappname>

Congratulations! You've built and shared a docker image

Push to IBM Containers on Bluemix
 Still in Ubuntu
 Open a browser and go to https://github.com/cloudfoundry/cli/releases
 Select the CF CLI of your choice.  If you're following the unbuntu thread here, just grab the Debian 64 bit.

 Install the IBM Container plugin to CF
  cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-linux_x64

 Login to Bluemix via CF
  cf login -a api.ng.bluemix.net
  cf ic init
  cf ic namespace  <-- remember your namespace
 
 Push your docker image to bluemix from your dockerhub
 cf ic cpi namespace/program registry.ng.bluemix.net/namespace/program:new

From any machine:
Configuring your docker image on Bluemix
 Open a browser
 Login to Bluemix
 Go to Catalog
 Go to Compute
 Go to Containers
 You should see your image listed.  It should have a green checkbox next to it.  If not, there's a problem and you can't go further.
 Click on your image to configure a container.
 Give it a name, use the smallest size possible, probably pico, request a public IP or not, wait for it to launch and start up.

Congratulations! You've built a docker container and pushed it to IBM Containers on Bluemix!
 

Sunday, July 10, 2016

Node.js - First Impressions

Well, I like this node.js.  I've done a small number of interesting project, and they came together faster than if I were going to do them in Java.  The learning curve is pretty easy, simpler than JEE.  I don't think that's a fair comparison though. And things run as soon as you finish typing, so there's no painful compile and packaging and deployment phase.

I haven't done much with it.  I wrote a drone controller with some simple MQTT, some REST calls, some AJAX handers, a tiny web app.  Enough that I think this is worth investing more time in.  I've dabbled in Node-Red, which is a kind of visual node.js, although they tell you it's really for connecting things.  Maybe that's it's sweet spot.

The only down side I see to node.js on Windows is that getting anything more complicated than what I've already done to work on a Windows machine requires some version of the Microsoft Visual C++ compiler in order for one of the modules, called gyp, to work.  StackOverflow is loaded with posts from people who simply could not get it working.  And I'm no better.  I've tried just about everything to get gyp to work, including several days of downloading and installing multiple gigabytes worth various versions of Visual Studio.  I'm beginning to think node.js might be the thing that turns me into a Linux guy.

Node-Red is a nice visual tool for stringing together node.js modules.  And if you stick to the prewritten nodes you're fine.  If you need to start writing your own Node-Red nodes, then give it some thought.  Maybe you're better off in node.js.  I quickly tested the limits of Node-Red when I wanted to implement a callback, which is a trivial thing in node.js

---
Followup:  What I had to do was
 1) Install Visual Studio C++ Community Edition
 2) npm config set msvs_version 2015
 3) npm -g install npm@next

I think that's all I did, and now it seems fine.

Wednesday, May 4, 2016

Working with Bluemix

This Developer Hat article is not really about coding.  It's more about how to easily use Bluemix to get started, and then build, deploy and run a Java application in the cloud.  For me, this would have been a fairly trivial exercise if I were developing a WAS app on my desktop.  But I imagined getting it deployed to the cloud was going to be hard.  I was wrong.

So today I wanted to write a simple app in Java, only because I know Java better than I know node.js or other languages.  The first step, is to search Bluemix for a starting point, and since I wanted something quick and dirty I just I started with a simple WAS Liberty Profile and a simple servlet.

Bluemix guides you pretty well, explaining how to download your sample code as well as the CF and Bluemix command line utilities.  I installed the utilities, and unzipped the sample code to my workspace. Even though I already have umpteen copies of Eclipse sitting around, Bluemix tells me I will need the Mars version and some add-ons, IBM Eclipse Tools for Bluemix and Liberty profile V8.5.5.5 (or later) runtime 

I already have Liberty up and running for some other projects I'm working on, so I skipped that one. And just pulled down Mars and the Tools for Bluemix.

Opened the new Eclipse, Import Existing Projects and pointed at the sample code I pulled from Bluemix.  I found the sample servlet class.  Made my changes.  Verified the descriptor.  Saved the WAR file.

I had to edit the YML file.  It tells CF how to build and deploy, and since I changed my servlet WAR file name, that had to go into the YML file.  After that I followed the instructions on Bluemix on how to use CF to upload.  A few minutes later I have a nice little servlet running on Bluemix.  I'm happy.



Friday, March 4, 2016

Node-RED

An amazing little message broker / flow manager...

Need to learn this in 2016...

http://nodered.org/docs/getting-started/installation

The download link was broken when I did it, so I just backtracked and pulled from here:
https://nodejs.org/dist/latest-v4.x/

The install takes a couple minutes

No-SQL

Learn CouchDB... it's what Cloudant is based on.

http://couchdb.apache.org/

JSON described arbitrary data.

MapReduce...