Created
April 9, 2017 06:37
-
-
Save konkon1234/648db63a2f12aab845814df5c7b58571 to your computer and use it in GitHub Desktop.
Vagrantfile template for ubuntu16.04 docker, docker-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
$is_windows = RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin/i | |
$is_osx = RbConfig::CONFIG['host_os'] =~ /darwin/i | |
Vagrant.configure("2") do |config| | |
config.vm.box = "bento/ubuntu-16.04" | |
config.vm.box_check_update = false | |
config.vm.network "forwarded_port", guest: 80, host: 18080 | |
config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.synced_folder "./", "/vagrant", mount_options: ['dmode=777', 'fmode=777'] | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "2048" | |
# for connection error. https://github.com/chef/bento/issues/682 | |
vb.customize ["modifyvm", :id, "--cableconnected1", "on"] | |
end | |
if $is_osx then | |
# require vagrant-triggers plugin | |
# port 80 -> 18080 | |
config.trigger.after [:provision, :up, :reload] do | |
system('echo "rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 18080" | sudo pfctl -ef - > /dev/null 2>&1') | |
system('echo "set packet filter 127.0.0.1:80 -> 127.0.0.1:18080"') | |
end | |
config.trigger.after [:halt, :destroy] do | |
system("sudo pfctl -df /etc/pf.conf > /dev/null 2>&1") | |
system('echo "reset packet filter"') | |
end | |
end | |
config.vm.provision "shell", inline: <<SCRIPT | |
# install docker, docker-compose | |
apt-get update | |
apt-get install -y curl linux-image-extra-$(uname -r) linux-image-extra-virtual | |
apt-get install -y apt-transport-https ca-certificates | |
curl -fsSL https://yum.dockerproject.org/gpg | sudo apt-key add - | |
apt-get install software-properties-common | |
add-apt-repository "deb https://apt.dockerproject.org/repo/ ubuntu-$(lsb_release -cs) main" | |
apt-get update | |
apt-get -y install docker-engine docker | |
curl -L https://github.com/docker/compose/releases/download/1.11.1/docker-compose-`uname -s`-`uname -m` > /usr/bin/docker-compose | |
chmod 755 /usr/bin/docker-compose | |
# mysql client | |
apt-get install mysql-client | |
SCRIPT | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment