Skip to content

Instantly share code, notes, and snippets.

@190ikp
Last active December 12, 2018 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 190ikp/5c9fe78f3d66443e7c8acc415d56eeec to your computer and use it in GitHub Desktop.
Save 190ikp/5c9fe78f3d66443e7c8acc415d56eeec to your computer and use it in GitHub Desktop.
customized Vagrantfile
#!/bin/bash
# dockerがインストール済みでないか確認
which docker > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Docker has been installed"
else
# docker install
apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
apt-get -y install docker-ce
echo "Docker install succeded!"
fi
# docker-composeがインストール済みでないか確認
which docker-compose > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Docker-Compose has been installed"
else
# docker-compose install
curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
echo "Docker-Compose install succeded!"
fi
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.network "forwarded_port", guest: 80, host: 80, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 443, host: 443, host_ip: "127.0.0.1"
config.vm.provider "virtualbox" do |vb|
vb.name = "test_server"
vb.memory = "2048"
# ここで64bitを指定しないと,うまく動いてくれないことがある(ホスト側が32bitの場合)
vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"]
end
config.vm.provision "shell", inline: <<-SHELL
# 仮想環境内のbashで以下を実行(root権限で実行される)
apt-get update
apt-get -y upgrade
# ホスト側のVagrantfileと同じディレクトリに移動
# =>同一ディレクトリに配置したシェルスクリプトを実行
cd /vagrant
./hoge.sh
# dockerインストール用のスクリプト
./docker_setup.sh
# 2回目以降の起動に備えてdocker-compose downしておく
docker-compose down
docker-compose up
SHELL
end
@190ikp
Copy link
Author

190ikp commented Dec 12, 2018

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