Skip to content

Instantly share code, notes, and snippets.

@jcdarwin
Created February 28, 2016 08:59
Show Gist options
  • Save jcdarwin/e1991320f1c4f3d1db2f to your computer and use it in GitHub Desktop.
Save jcdarwin/e1991320f1c4f3d1db2f to your computer and use it in GitHub Desktop.
Vagrant file for installing Dokku on an EC2 instance
Vagrant::configure('2') do |config|
config.vm.define :dokku, autostart: false do |box|
box.vm.box = 'trusty'
box.vm.box_url = 'https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box'
box.vm.hostname = 'dokku.me'
box.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
aws.keypair_name = 'aws'
# As per the Amazon EC2 AMI Locator
aws.ami = 'ami-4f32142c'
aws.region = 'ap-southeast-2'
aws.instance_type = 't2.micro'
# Customize this to the id of the security group you're using
aws.security_groups = 'production'
# To mount EBS volumes
aws.block_device_mapping = [
{
:DeviceName => "/dev/sdb",
:VirtualName => "ephemeral0"
},
{
:DeviceName => "/dev/sdc",
:VirtualName => "ephemeral1"
}
]
override.ssh.username = 'ubuntu'
# Customize this to your AWS keypair path
override.ssh.private_key_path = '~/.ssh/aws.pem'
end
# To make sure we use EBS for our tmp files
box.vm.provision "shell" do |s|
s.privileged = true
s.inline = %{
mkdir -m 1777 /mnt/tmp
echo 'export TMPDIR=/mnt/tmp' > /etc/profile.d/tmpdir.sh
}
end
# To make sure packages are up to date
box.vm.provision "shell" do |s|
s.privileged = true
s.inline = %{
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get --yes --force-yes upgrade
}
end
# Install dokku as per http://dokku.viewdocs.io/dokku/getting-started/install/debian/
box.vm.provision "shell" do |s|
s.privileged = true
s.inline = %{
export DEBIAN_FRONTEND=noninteractive
echo "install prerequisites"
sudo apt-get update -qq > /dev/null
sudo apt-get install -qq -y apt-transport-https
echo "setup unattended installation"
echo "dokku dokku/vhost_enable boolean true" | sudo debconf-set-selections
echo "dokku dokku/hostname string dokku.me" | sudo debconf-set-selections
echo "install docker"
sudo apt-get install lxc wget bsdtar curl
sudo apt-get install linux-image-extra-$(uname -r)
sudo modprobe aufs
sudo usermod -aG docker ubuntu
wget -nv -O - https://get.docker.com/ | sh
echo "install dokku"
wget -nv -O - https://packagecloud.io/gpg.key | apt-key add -
echo "deb https://packagecloud.io/dokku/dokku/ubuntu/ trusty main" | sudo tee /etc/apt/sources.list.d/dokku.list
sudo apt-get update -qq -y > /dev/null
sudo apt-get install -qq -y dokku
sudo dokku plugin:install-dependencies --core
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment