Tuesday, October 4, 2011

Ubuntu/VirtualBox/Java Team Development Stack - Part II

Part II - Install the Development Stack.
Continued from Part I

Having a virtual machine with Ubuntu installed, we now need the developer tools in our stack.

My target developer's stack has:

  1. Java JDK
  2. Eclipse
  3. Ant
  4. jEdit
  5. Firefox (or Chrome)
  6. Tomcat
  7. MySQL 
  8. MySQL Client
  9. DropBox
It's worth installing Ubuntu Tweak. At the least, this gives us the window icons on the upper-right corner. Open a browser and go to http://ubuntu-tweak.com/. Install that.From within that, I also found the Chrome browser install and did that.

The approach Ubuntu uses for typical software installation is through the "Ubuntu Software Center" which is invoked from the bottom of the Applications menu. Easiest is to use the search box to find the software we want and then choose the version (if there are options) to install. I simply searched for and installed each package. Some notes:
  1. Java JDK: I chose the "OpenJDK Development Kit".
  2. Tomcat is installed on port 8080. Something else must be running on port 80 so I wasn't able to change the tomcat port.
  3. Tomcat installs as a service. As such, it can be stopped and started: service tomcat6 stop|start|restart
  4. I added a manager role and user ID/Password so I can access the tomcat manager and use the Eclipse/Ant deploy tasks.
  5. I created a new folder in home: /home/projects and made it read/write/execute accessible to the users group. 
  6. When I installed dropbox (by going to the www.dropbox.com website and installing from there), I pointed Dropbox at the projects directory so that those files would be under /projects.

Ubuntu/VirtualBox/Java Team Development Stack - Part I

Part I - Setting up a Virtual Machine and Ubuntu

A controlled java web development stack for a distributed development team.  I did this a few times before but never documented it, and (of course) versions of the tools have all moved on. But I have to resurrect it, so this time I think I'll write it up. No where near as easy as Dave Winer's EC2 for Poets (http://poets.scripting.com/), but he's a much better writer than am I!

So, the idea is this: several developers; some co-located and others not; working on a web project being developed in Java. This project is also using MySQL for an underlying database. Code is managed in a remote CVS repository. What I want to create is a controlled environment in which each developer has the same set of tools and test data against which to work. The answer: a virtual machine with all the tools installed and configured so that I can simply deliver a copy of the VM disk image to each developer. I've played with this before in VMWare and some other virtual machine kits that I don't recall, but most recently in Oracle's VirtualBox. So I'm repeating that experience here. It  bears noting that I am doing this stack creation on a Windows Vista 32-bit laptop (no flaming please). But I believe the overall approach here would work on pretty much any host machine. Also of note: since I don't want to deal with licenses (and fees) for virtual machines that I send out to developers, I am using Linux Ubuntu as the virtual client. This being a java development project, what we develop is (or certainly should be) portable across different operating systems, but the production target for this is also Linux, though not Ubuntu.

My target developer's stack has:

  1. Java JDK
  2. Eclipse
  3. Ant
  4. jEdit
  5. Firefox (or Chrome)
  6. Tomcat
  7. MySQL
  8. A VPN connection for CVS
In addition, there needs to be a way to share files from the host machine to the virtual machine. Here are the rough steps I followed:

A. Create an ISO Image of Ubuntu:
  1. Download Ubuntu (http://www.ubuntu.com/download/ubuntu/download). 
  2. The ISO image will need to be available to VirtualBox for installation, either on a CD or a USB drive.  I use a USB drive. Just copy the ISO image to that.
B. Set up a Virtual Machine with Ubuntu:
  1. VirtualBox: https://www.virtualbox.org/wiki/Downloads. This is  simple enough to install - just follow the steps and accept the defaults. Once it is installed, start it and create a new virtual machine.
  2. New Virtual Machine: I chose Linux/Ubuntu and then set memory to 1Gb.
  3. New "Hard Disk": I set it to dynamically expanding.
  4. At this point, I'm done creating the virtual machine - I need to install Ubuntu. By clicking "start" on the newly created machine, I get the "first run" wizard. From there, point to the USB drive from A. above.
  5. Follow the setup for Ubuntu. 
C. Create a root Password.

By default, Ubuntu is installed without a root login. I'm guessing this is for security reasons. But these developer VMs are not really subject to security issues and having the ability to run as root makes a lot of things easier. So I add a root password, enabling me to su and run as root when I need.

  1. sudo passwd root
First, you'll have to enter your password. Then the password you want for root.

D. Add my ID to the "users" group.
I found that my user ID was in its own group. I added "users" as my group so that I can access common folders more readily.

E. Install Guest Additions

This is a big/important key step. It makes many of the hardware and device features of the host computer pass through to the virtual machine. Like the screen size/resolution. And others.

  1. There is a virtual machine menu bar with a "devices" menu. This has a "Install Guest Additions..." item. Clicking this will *not* actually install the guest additions; it only mounts the guest additions as a virtual drive. So I did this, but then still had to run the actual install.
  2. After the mount, open a terminal window and cd to the mount for the additions. These seem to be under /media.
  3. Run the autorun.sh (sh ./autorun.sh). I switch to root before doing this (su).
  4. Restart the server.
F. Ensure Networking Works.
Since we need to access CVS over a VPN, we need the VPN access to work. For our purposes, each developer has VPN access from the host machine (my laptop). So I want this to "pass through" to the virtual machine. I'm not a networking guy, so I don't know much about this, but it seems that by setting the network adapter in the virtual machine to "NAT" (which seems to be the default anyway), I go the pass-through I wanted. Perhaps someone more knowledgeable than me can elucidate? Anyway, I simply tested this by connecting to the VPN and pinging a machine on our internal network.

G. Set up Sharing.
We'll want to be able to share files from the host file system to the virtual machine file system. This means setting up a Shared folder.
  1. On the host machine, create a folder (I called it "Sharing" and located it in the root).
  2. In the Virtual Machine, create a permanent share - from the "Devices" menu, select "Shared Folders..." and create a new share. I created a "permanent", "Auto Mounted" share and named it Sharing. 
  3. After restarting the VM, this share is now found in /media/sf_Sharing.
  4. I had to change my user ID and add "vboxsf" as a group to be able to access this.

Continued: Part II - Install the Development Stack.