This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Vagrantfile
137 lines (112 loc) · 4.56 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.define "gameontext" do |vm|
end
config.vm.provider "virtualbox" do |v|
v.memory = 3072
v.cpus = 2
v.name = "gameontext"
end
#fix 'stdin is not a tty' output.
config.vm.provision :shell, inline: "(grep -q -E '^mesg n$' /root/.profile && sed -i 's/^mesg n$/tty -s \\&\\& mesg n/g' /root/.profile && echo 'Ignore the previous error about stdin not being a tty. Fixing it now...') || exit 0;"
#forward port 80 to the docker host, so we can access gameontext's web page.
config.vm.network(:forwarded_port, guest: 80, host: 9980)
config.vm.network(:forwarded_port, guest: 443, host: 9943)
# Run as Root -- install git, latest docker, bx cli
config.vm.provision :shell, :inline => <<-EOT
export DEBIAN_FRONTEND=noninteractive
apt-get -qq update
apt-get -qq -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
echo 'Installing Git & Curl'
apt-get -qq install -y \
git \
curl \
openjdk-8-jdk
echo 'Set up HTTPS repository'
apt-get -qq install -y \
apt-transport-https \
ca-certificates \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
echo 'Install Docker CE'
apt-get -qq update
apt-get -qq install -y docker-ce
echo 'Add vagrant to docker group'
usermod -aG docker vagrant
ls -al /var/run/docker.sock
chgrp docker /var/run/docker.sock
chmod 775 /var/run/docker.sock
DOCKER_COMPOSE_VERSION=1.15.0
curl -sSL https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose 2>/dev/null
chmod +x /usr/local/bin/docker-compose
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl > /usr/local/bin/kubectl 2>/dev/null
chmod +x /usr/local/bin/kubectl
if /usr/local/bin/bx > /dev/null
then
echo 'Updating Bluemix CLI'
/usr/local/bin/bx update 2>/dev/null
else
echo 'Installing Bluemix CLI'
sh <(curl -fssSL https://clis.ng.bluemix.net/install/linux 2>/dev/null) 2>/dev/null
fi
EOT
# Run as vagrant user (not yet in docker group): bx plugins, profile script
config.vm.provision :shell, privileged: false, :inline => <<-EOT
PLUGINS=$(bx plugin list)
if echo $PLUGINS | grep dev
then
/usr/local/bin/bx plugin update dev -r Bluemix
else
echo 'Installing Bluemix dev plugin'
/usr/local/bin/bx plugin install dev -r Bluemix
fi
if echo $PLUGINS | grep container-service
then
/usr/local/bin/bx plugin update container-service -r Bluemix
else
echo 'Installing Bluemix container-service plugin'
/usr/local/bin/bx plugin install container-service -r Bluemix
fi
if echo $PLUGINS | grep container-registry
then
/usr/local/bin/bx plugin update container-registry -r Bluemix
else
echo 'Installing Bluemix container-registry plugin'
/usr/local/bin/bx plugin install container-registry -r Bluemix
fi
touch ~/.Xauthority
# Enable Gradle Daemon
mkdir -p /home/vagrant/.gradle
touch /home/vagrant/.gradle/gradle.properties
echo "org.gradle.daemon=true" >> /home/vagrant/.gradle/gradle.properties
# Indicate this is a vagrant VM
echo 'export DOCKER_MACHINE_NAME=vagrant' | tee -a /home/vagrant/.profile
# Don't try to run kubenetes in this VM unless you know what you're doing
echo 'export GO_DEPLOYMENT=docker' | tee -a /home/vagrant/.profile
# By default this working directory is mapped to /vagrant,
# automatically change directories on login
echo 'cd /vagrant' | tee -a /home/vagrant/.profile
cd /vagrant
chmod +x go*.sh docker/go*.sh kubernetes/go*.sh bin/*.sh
EOT
# Run as vagrant user: Always start things
config.vm.provision :shell, privileged: false, run: "always", :inline => <<-EOT
echo 'To start Game On! :'
echo '> vagrant ssh'
echo '> ./go-admin.sh setup'
echo '> ./go-admin.sh up'
echo ""
echo 'To test for readiness: https://gameon.127.0.0.1.nip.io/health'
echo ""
echo 'To wait for readiness:'
echo '> ./docker/go-run.sh wait'
echo 'To watch :popcorn: : '
echo '> ./docker/go-run.sh logs'
EOT
end