build your own node appliance

so... i figured it would be nice to explain what it is i'm doing to build my node appliance.

  1. install virtualbox

    if you haven't done so already, go to http://www.virtualbox.org/, download and install sun's oracle's virtualbox package for your operating system.

  2. download and install debian

    i'm using debian 5.0.9 (aka "lenny.") it's stable, and still gets some support. you can download the netinst image at  http://www.debian.org/releases/lenny/debian-installer/ and use it to create a new virtual machine

  3. create a new virtual machine

    use virtualbox to create a new virtual machine. here are the configuration parameters i use:

     name nodify.us node appliance (debian lenny i386 32-bit)
     OS Type Linux / Debian
     base memory 512 Mb
     network adapter 1 NAT
     network adapter 2 Host-only
     storage 20.00 Gb

  4. install linux

    i pretty much use the defaults for everything. but here are some critical non-defaults i use:

     host name helium
     domain name l.nodify.us
     user full name John Lee
     username jlee
     password supertaster

    don't freak! we'll be removing this preconfigured password later in the build process and replacing it with a service that allows users to create a new user account on the appliance.

  5. add the backports repository and update your linux install

    login as root and add the following line to /etc/apt/sources.list:

    deb http://backports.debian.org/debian-backports lenny-backports main
    deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen

    and add the mongodb repository key with this command:

    apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

  6. it's likely a few patches have been released since the install image was produced, so it's probably a good idea to use apt-get to update the system. execute these commands as root to fix that:

    apt-get update
    apt-get upgrade

  7. install a few important packages

    the following packages allow you to build packages like node and the virtual box guest additions. install them with the following command (as root):

    apt-get install build-essential dkms linux-headers-`uname -r` libcurl4-openssl-dev samba curl openssh-server nginx git-core sudo mongodb-10gen

  8. activate host only network on eth1

    networking isn't automatically enabled for the host-only network, so adding the following lines to /etc/network/interfaces should do the trick:

    auto eth1
    iface eth1 inet static
    address 192.168.56.2
    netmask 255.255.255.0
    network 192.168.56.0
    broadcast 192.168.56.255

  9. install guest additions

    virtualbox guest additions is a set of tools and a linux device driver that provides a better integration experience. to install it, start by selecting the menu item "Devices > Install Guest Additions..."

    from the command line, mount the cd-rom drive with the command:

    mount /dev/cdrom /mnt

    and then execute the virtual additions install program with the command:

    /mnt/VBoxLinuxAdditions.run --nox11

  10. configure samba

    samba is an open source SMB / CIFS file server for unixish systems. unlike NFS or AFP, which some consider to be superior, SMB is supported on MacOS X, WinTel and most linux distros. to configure samba, add the following lines to the /etc/samba/smb.conf

    [homes]
       read only = No
       browseable = No
       create mask = 0644
       directory mask = 0755

  11. finally... restart the virtual guest OS to make sure the new kernel module is installed:

    /sbin/shutdown -r now 

  12. login as jlee and install node

    start by creating some directories in jlee's home:

    mkdir Downloads Projects

    now go to the node and mongo websites and find the URLs to download the install packages. i like to cd into the Downloads directory and use wget to fetch the tar files:

    cd ~/Downloads
    wget http://nodejs.org/dist/v0.6.6/node-v0.6.6.tar.gz

    current package versions will, no doubt, be different than when i wrote this, so you probably want to grab them instead of the versions i list here.

    make and install node
    cd ~/Projects
    tar xzvf ../Downloads/node-v0.6.6.tar.gz
    cd node-v0.6.6
    ./configure --prefix=/usr/local
    make

    it's now a good idea to test the build with the following command. if you get errors, you probably want to fix them before continuing.

    sudo make test

    assuming everything here works well, go ahead and install:

    sudo make install

  13. install npm packages
    now we use npm to install a number of nice packages:

    sudo npm install -g mongodb express node-dev

  14. download and install the config app

    this is a simple express.js app that listens on port 2525 on the host-only interface and configures the end user's account. installing it is pretty straight-forward:

    sudo -s
    curl http://content.nodify.us/appliance/larb.sh | sh

  15. delete the jlee account and shutdown

    sudo -s
    userdel -r jlee
    shutdown -h now

  16. export the virtual machine as an appliance

    there are command line options to do this, but the simplest way is to click on the VirtualBox "File > Export Appliance..." menu item.

Comments