2013-05-14 02:10:00 -04:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
BOX_NAME = "docker-ci"
|
|
|
|
BOX_URI = "http://files.vagrantup.com/precise64.box"
|
|
|
|
AWS_AMI = "ami-d0f89fb9"
|
|
|
|
DOCKER_PATH = "/data/docker"
|
|
|
|
CFG_PATH = "#{DOCKER_PATH}/testing/buildbot"
|
|
|
|
BUILDBOT_IP = "192.168.33.41"
|
|
|
|
on_vbox = File.file?("#{File.dirname(__FILE__)}/.vagrant/machines/default/virtualbox/id") | \
|
|
|
|
Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty? & \
|
|
|
|
(on_vbox=true; ARGV.each do |arg| on_vbox &&= !arg.downcase.start_with?("--provider") end; on_vbox)
|
|
|
|
USER = on_vbox ? "vagrant": "ubuntu"
|
|
|
|
|
|
|
|
Vagrant::Config.run do |config|
|
|
|
|
# Setup virtual machine box. This VM configuration code is always executed.
|
|
|
|
config.vm.box = BOX_NAME
|
|
|
|
config.vm.box_url = BOX_URI
|
|
|
|
config.vm.share_folder "v-data", DOCKER_PATH, "#{File.dirname(__FILE__)}/.."
|
|
|
|
config.vm.network :hostonly, BUILDBOT_IP
|
|
|
|
|
2013-06-28 12:21:34 -04:00
|
|
|
|
2013-05-14 02:10:00 -04:00
|
|
|
# Deploy buildbot and its dependencies if it was not done
|
|
|
|
if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty?
|
2013-08-14 13:12:08 -04:00
|
|
|
# Add memory limitation capabilities
|
|
|
|
pkg_cmd = 'sed -Ei \'s/^(GRUB_CMDLINE_LINUX_DEFAULT)=.+/\\1="cgroup_enable=memory swapaccount=1 quiet"/\' /etc/default/grub; '
|
|
|
|
# Install new kernel
|
|
|
|
pkg_cmd << "apt-get update -qq; apt-get install -q -y linux-image-generic-lts-raring; "
|
2013-05-14 02:10:00 -04:00
|
|
|
# Deploy buildbot CI
|
|
|
|
pkg_cmd << "apt-get install -q -y python-dev python-pip supervisor; " \
|
|
|
|
"pip install -r #{CFG_PATH}/requirements.txt; " \
|
|
|
|
"chown #{USER}.#{USER} /data; cd /data; " \
|
2013-07-05 00:43:46 -04:00
|
|
|
"#{CFG_PATH}/setup.sh #{USER} #{CFG_PATH} #{ENV['BUILDBOT_PWD']} " \
|
|
|
|
"#{ENV['IRC_PWD']} #{ENV['IRC_CHANNEL']} #{ENV['SMTP_USER']} " \
|
2013-07-29 12:45:19 -04:00
|
|
|
"#{ENV['SMTP_PWD']} #{ENV['EMAIL_RCP']}; " \
|
|
|
|
"#{CFG_PATH}/setup_credentials.sh #{USER} " \
|
|
|
|
"#{ENV['REGISTRY_USER']} #{ENV['REGISTRY_PWD']}; "
|
2013-05-14 02:10:00 -04:00
|
|
|
# Install docker dependencies
|
|
|
|
pkg_cmd << "apt-get install -q -y python-software-properties; " \
|
2013-06-28 12:21:34 -04:00
|
|
|
"add-apt-repository -y ppa:dotcloud/docker-golang/ubuntu; apt-get update -qq; " \
|
2013-08-14 13:12:08 -04:00
|
|
|
"DEBIAN_FRONTEND=noninteractive apt-get install -q -y lxc git mercurial golang-stable aufs-tools make; "
|
2013-05-14 02:10:00 -04:00
|
|
|
# Activate new kernel
|
|
|
|
pkg_cmd << "shutdown -r +1; "
|
|
|
|
config.vm.provision :shell, :inline => pkg_cmd
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Providers were added on Vagrant >= 1.1.0
|
|
|
|
Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
|
|
|
|
config.vm.provider :aws do |aws, override|
|
2013-06-28 12:21:34 -04:00
|
|
|
aws.tags = { 'Name' => 'docker-ci' }
|
2013-05-14 02:10:00 -04:00
|
|
|
aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
|
|
|
|
aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
|
|
|
|
aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
|
|
|
|
override.ssh.private_key_path = ENV["AWS_SSH_PRIVKEY"]
|
|
|
|
override.ssh.username = USER
|
|
|
|
aws.ami = AWS_AMI
|
|
|
|
aws.region = "us-east-1"
|
|
|
|
aws.instance_type = "m1.small"
|
|
|
|
aws.security_groups = "gateway"
|
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.provider :virtualbox do |vb|
|
|
|
|
end
|
|
|
|
end
|