Skip to content

Instantly share code, notes, and snippets.

@Patru
Last active August 29, 2015 14:27
Show Gist options
  • Save Patru/e19947923ff3fd7f5ca9 to your computer and use it in GitHub Desktop.
Save Patru/e19947923ff3fd7f5ca9 to your computer and use it in GitHub Desktop.
Deployment-Setup for ruby 1.9.2

Well, my Yosemite Mac refused to run Ruby 1.9.2, but I still had these apps running with this stubborn hoster, so I needed a way to not just develop, but also deploy these things. Capistrano would easily cut it, but it usually runs out of the same directory. Deploying from vagrant would be an option, but I wanted something more "durable" which would work for several setups with the same credentials. Ubuntu headless server would do nicely for this, so i used these instructions to get it up and running:

https://leemendelowitz.github.io/blog/ubuntu-server-virtualbox.html

This mostly worked all right, with just a minor oversight of his part which became apparent since I wanted just one deployment disk which I could use for several deployments. The variable he defines is not used, so I ended up doing the following:

VM_NAME="Deploy-1.9.2-server"
UBUNTU_ISO_PATH=~/Downloads/ubuntu-14.04.1-server-amd64.iso
VM_HD_PATH="DeployDisk.vdi" # The path to VM hard disk (ended up in an inconvenient place like this).
SHARED_PATH=~/projects # Share my projects directory with the VM


vboxmanage createvm --name $VM_NAME --ostype Ubuntu_64 --register
vboxmanage createhd --filename $VM_HD_PATH --size 32768     # error here
vboxmanage storagectl $VM_NAME --name "SATA Controller" --add sata --controller IntelAHCI
vboxmanage storageattach $VM_NAME --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium $VM_HD_PATH
vboxmanage storagectl $VM_NAME --name "IDE Controller" --add ide
vboxmanage storageattach $VM_NAME --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium $UBUNTU_ISO_PATH
vboxmanage modifyvm $VM_NAME --ioapic on
vboxmanage modifyvm $VM_NAME --memory 1024 --vram 128
vboxmanage modifyvm $VM_NAME --nic1 nat
vboxmanage modifyvm $VM_NAME --natpf1 "guestssh,tcp,,2222,,22"
vboxmanage modifyvm $VM_NAME --natdnshostresolver1 on
vboxmanage sharedfolder add $VM_NAME --name shared --hostpath $SHARED_PATH --automount

setting up the linux box went along https://gist.github.com/Patru/00a461e7ac5d65462d04

now I could start the server as in

vboxmanage startvm Deploy-1.9.2-server --type headless

and log into it using

ssh -p 2222 patru@localhost

unfortunately it became clear really quickly that this clashed with the port number my vagrant instance was using for its ssh port forwarding. Seeing what is stored to known_hosts it does seem like a really good idea to keep thes separate. In the VirtualBox docs you find the following command for removing a port forwarding (for which the vm should be halted of course, use vboxmanage controlvm Deploy-1.9.2-server poweroff to get this done):

VBoxManage modifyvm Deploy-1.9.2-server --natpf1 delete "guestssh"

You can add it back as above, I ended up using

vboxmanage modifyvm Deploy-1.9.2-server --natpf1 "guestssh,tcp,,2342,,22"

which would require me to use

ssh -p 2342 patru@localhost

which is of course too cumbersome to remember, so I aliased it of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment