NOTE: The Macintosh instructions are a bit different. I’ll write those up later.
Download node.js bitnami vm image
Go to bitnami.com and grab the node.js appliance image. Extract all, rename resulting folder to VM-InqSim-Ubuntu
Then, install on VirtualBox (here are instructions). Basically:
- unpack archive
- make new 64-bit Ubuntu VM with 512MB of memory and bridged networking.
- for hard disk, use existing image, and choose the main
.vmdk image(not the
s001, etc files).
Start it up! Pick a new password when prompted. I’m using
inq!nami for all our test images, which is fine because this is a private test server on my home network.
Follow instructions here:
sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf sudo start ssh
Update the Package Cache for Apt-Get, then Apply Upgrades
(this can take quite some time)
sudo apt-get update sudo apt-get upgrade
OPTIONAL Install JED, an emacs-like editor
Alternatively, you could skip this and use vi or nano. Pick one:
sudo apt-get install mg sudo apt-get install jed sudo apt-get install emacs23-nox (this is what I use)
(or search with
sudo apt-cache search <string>)
Switch to Static IP
A static ip will allow me to address this machine by hostname, which I will manually set-up.
First, assign the static IP. I’m using 192.168.1.11 for this VM/
sudo su - emacs /etc/network/interfaces iface eth0 inet static address 192.168.1.11 netmask 255.255.255.0 gateway 192.168.1.1</p> <p>emacs /etc/resolvconf/resolve.conf.d/base add these lines: nameserver 184.108.40.206 nameserver 220.127.116.11</p> <p>/etc/init.d/networking restart
Then, assign hostname manually:
emacs /etc/hostname so it contains: inqsim.vbox</p> <p>emacs /etc/hosts as follows: 192.168.1.11 inqsim.vbox</p> <p>reboot now</p> <p>... ifconfig (to check settings took) hostname (to check settings took)
Prepare Mimosa Development Environment
This is a good time to take a SNAPSHOT in VirtualBox in case something screws up. First shut down the virtualbox safely by typing:
Then, in VirtualBox, take a snapshot so you can revert back to this pristine server state if you want to try other stuff.
sudo apt-get install git-core
Mimosa is a node module, so we load it with npm (see instructions). In our case, though, we don’t want to have to
sudo everytime we want to execute a mimosa command. That would suck. So we have to modify our node npm configuration file before installing mimosa.
(make sure you are user bitnami, not root)</p> <p>cd ~ echo prefix = ~/.node >> ~/.npmrc emacs ~/.bashrc ... add line PATH="$HOME/.node/bin:$PATH" before 'export PATH' source .bashrc echo $PATH ... make sure PATH is updated
The .npmrc file tells npm to install modules in the current user's directory under .node, and edits the user's path so running npm commands happens out of our own user directory. Theoretically, not requiring root permission for everything.
With that set, we can install our node module, mimosa, as a regular user without the sudo command!
npm install -g mimosa
Retrieving our Durandal-based Project
I have just put it on bitbucket, so I'm using the following to retrieve it from the repo:
(make sure you are user bitnami, not root)</p> <p>cd ~ mkdir Dev cd Dev git clone https://firstname.lastname@example.org/dseah/inqsimtest-durandal.git cd inqsimtest-durandal
…and everything is retrieved and built. It will take a while the first time through.
Pushing your changes back up to the repo (the origin master, I think it's called), here's how to modify your changed files.
git status git commit -m "modified these files note" git push
The quick way is to do
git pull, which will do a
get fetch followed by a
git merge without asking you for permission.
Since the bitnami node.js VM is headless (no graphics), we use the host OS browser to view the application. First, you need to modifu the Ubuntu firewall rules to allow port 3000 through. You just need to execute the command once, and it will be set forever.
sudo ufw allow 3000
Now, you can use mimosa to compile and spawn a local server that watches for changes to your source code.
mimosa watch --server
Then on the host machine, browse to http://192.168.1.11:3000 or http://inqsim.vbox:3000to see the app running. You can
ssh into the vm to open new editor windows, and live reload will work as long as the server is running (you started it with
mimosa watch -s or
mimosa watch --server).
To make ssh from the host (the windows machine) easier, we can assign hostname in
/etc/hosts of host computer. On windows, it’s
Run Notepad as Adminstrator by right-clicking the icon and choose “Run As Administrator”. Make sure that “all files” is the filter setting when opening it with Notepad, so you can see thoe
hosts file. In the file add the following line:
Then, try SSHing into the local host (
ssh 192.168.1.11 or
ssh inqsim.vbox) using PuTTY. You may want to set PuTTY’s xterm (under Data-Connection-Term) to
EXPERIMENTAL Guest Folder Support
(this doesn’t work on Windows, perhaps due to lack of symlink support? Haven’t tried on Mac)
It would be nice if we could edit the files on the guest VM using a nice editor on the host, instead of using the text-only environment of the Bitnami VM. VirtualBox has shared folder support. You can share a folder on the host so it appears within the guest.
There’s two parts to this config. First, use the VirtualBox Manager app on the host to:
- poweroff the vm
- edit setting ‘Shared Folders’
- add a new ‘Machine Folder’, and pick a folder in your host’s filesystem along with a “sharename” (e.g. vm_inqsimdev)
- save settings, and boot the vm
Next you need to mount the shared folder you just created, but you also have to build the support code into the linux kernel. You’ll compile this from “VirtualBox Guest Additions”, which is virtual CD you mount under the Devices->Insert Guest Additions CDROM menu.
You will need to install some additional development tools and run a script:
sudo apt-get install linux-headers-<code>uname -r</code> dkms</p> <p>sudo mkdir /media/cdrom sudo mount /dev/cdrom /media/cdrom cd /media/cdrom sudo /VBoxLinuxAdditions.run
You'll probably see a "FAILURE NO X", but hopefully everything else is built (sharing is what we want). Using the instructions here:
sudo emacs /etc/fstab -- add the following line (put spaces between each entry): vm_inqsimdev /home/bitnami/vm_inqsim vboxsf defaults,uid=1000,gid=1000 0 0</p> <p>sudo reboot
fstab (the file system table) to add a new hard virtual storage space, our shared folder
vm_inqsimdev, to the mountpoint
/home/bitnami/inqsim. The values for uid and gid are obtained using
id -u bitnami and
id -g bitnami respectively.
Now we can grab our source through git as described above:
cd ~/vm_inqsim git clone https://email@example.com/dseah/inqsimtest-durandal.git cd inqsimtest-durandal mimosa build
We have to move the .node directory into this file system, though…FAIL to build…look at this later.
EXPERIMENTAL Samba networking
If the above guest folder doesn't work, you could install Samba. So let’s install it (instructions):
sudo su - apt-get install samba samba-common emacs /etc/nsswitch.conf -- add “wins” before the last item on the hosts line cp /etc/samba/smb.conf /etc/samba/smb.conf.bak</p> <p>emacs /etc/samba/smb.conf .. copied smb.conf template from install instructions link (above) .. edit workgroup to match your workgroup setting on the host machine .. edit hostname to BitnamiVM</p> <p>service smbd restart service nmbd restart ufw allow samba
If you don't see the BITNAMIVM show up, make sure that the VirtualBox networking is set to "bridged".
The following configuration changes adds a "bitnami" account for sharing (instructions):
emacs /etc/samba/smb.conf</p> <p>.. add this section to end of smb.conf .. change path to point to where the dev directory is</p> <p>[bitnami] comment = Bitnami Dev browseable = yes path = /home/bitnami/ guest ok = yes force user = bitnami read only = no create mask = 0775 directory mask = 0755
This is a wide-open account, but if it’s running at home it’s probably OK. I can probably make it so it’s running in a host mode that is more secure.
If you have problems seeing files, check the
/var/log/samba/ folder in the VM for information about what’s going wrong. Correct paths and permissions are critical.