-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
154 lines (136 loc) · 6.58 KB
/
Vagrantfile
File metadata and controls
154 lines (136 loc) · 6.58 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
# Forward Flask and Kubernetes ports
config.vm.network "forwarded_port", guest: 8001, host: 8001, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 5000, host: 5000, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.33.10"
# Provider-specific configuration
config.vm.provider "virtualbox" do |vb|
# Customize the amount of memory on the VM:
vb.memory = "1024"
vb.cpus = 1
# Fixes some DNS issues on some networks
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
# Copy your .gitconfig file so that your git credentials are correct
if File.exists?(File.expand_path("~/.gitconfig"))
config.vm.provision "file", source: "~/.gitconfig", destination: "~/.gitconfig"
end
# Copy your ssh keys for github so that your git credentials work
# if File.exists?(File.expand_path("~/.ssh/id_rsa"))
# config.vm.provision "file", source: "~/.ssh/id_rsa", destination: "~/.ssh/id_rsa"
# end
# if File.exists?(File.expand_path("~/.ssh/id_rsa.pub"))
# config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/id_rsa.pub"
# end
# Copy your IBM Clouid API Key if you have one
if File.exists?(File.expand_path("~/.bluemix/apiKey.json"))
config.vm.provision "file", source: "~/.bluemix/apiKey.json", destination: "~/.bluemix/apiKey.json"
end
# Copy your .vimrc file so that your VI editor looks right
if File.exists?(File.expand_path("~/.vimrc"))
config.vm.provision "file", source: "~/.vimrc", destination: "~/.vimrc"
end
######################################################################
# Setup a Python development environment
######################################################################
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y git zip tree python-pip python-dev
apt-get -y autoremove
pip install --upgrade pip
# Install app dependencies
cd /vagrant
sudo pip install -r requirements.txt
SHELL
######################################################################
# Add CouchDB docker container
######################################################################
config.vm.provision "shell", inline: <<-SHELL
sudo mkdir -p /opt/couchdb/data
sudo chown vagrant:vagrant /opt/couchdb/data
SHELL
# Add CouchDB docker container
# docker run -d --name couchdb -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=pass couchdb
config.vm.provision "docker" do |d|
d.pull_images "couchdb"
d.run "couchdb",
args: "--restart=always -d --name couchdb -p 5984:5984 -v /opt/couchdb/data:/opt/couchdb/data -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=pass"
end
######################################################################
# Setup a Bluemix and Kubernetes environment
######################################################################
config.vm.provision "shell", inline: <<-SHELL
echo "\n************************************"
echo " Installing IBM Cloud CLI..."
echo "************************************\n"
# Install IBM Cloud CLI as Vagrant user
sudo -H -u vagrant sh -c 'curl -sL http://ibm.biz/idt-installer | bash'
sudo -H -u vagrant sh -c 'ibmcloud config --usage-stats-collect false'
sudo -H -u vagrant sh -c "echo 'source <(kubectl completion bash)' >> ~/.bashrc"
sudo -H -u vagrant sh -c "echo alias ic=/usr/local/bin/ibmcloud >> ~/.bash_aliases"
echo "\n"
echo "If you have an IBM Cloud API key in ~/.bluemix/apiKey.json"
echo "You can login with the following command:"
echo "\n"
echo "ibmcloud login -a https://api.ng.bluemix.net --apikey @~/.bluemix/apiKey.json"
echo "\n"
echo "\n************************************"
echo " For the Kubernetes Dashboard use:"
echo " kubectl proxy --address='0.0.0.0'"
echo "************************************\n"
#added postgress to vagrantfile
SHELL
######################################################################
# Add CouchDB docker container
######################################################################
config.vm.provision "shell", inline: <<-SHELL
sudo mkdir -p /opt/couchdb/data
sudo chown vagrant:vagrant /opt/couchdb/data
SHELL
# Add CouchDB docker container
# docker run -d --name couchdb -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=pass couchdb
config.vm.provision "docker" do |d|
d.pull_images "couchdb"
d.run "couchdb",
args: "--restart=always -d --name couchdb -p 5984:5984 -v /opt/couchdb/data:/opt/couchdb/data -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=pass"
end
######################################################################
# Setup a Bluemix and Kubernetes environment
######################################################################
config.vm.provision "shell", inline: <<-SHELL
echo "\n************************************"
echo " Installing IBM Cloud CLI..."
echo "************************************\n"
# Install IBM Cloud CLI as Vagrant user
sudo -H -u vagrant sh -c 'curl -sL http://ibm.biz/idt-installer | bash'
sudo -H -u vagrant sh -c 'ibmcloud config --usage-stats-collect false'
sudo -H -u vagrant sh -c "echo 'source <(kubectl completion bash)' >> ~/.bashrc"
sudo -H -u vagrant sh -c "echo alias ic=/usr/local/bin/ibmcloud >> ~/.bash_aliases"
echo "\n"
echo "If you have an IBM Cloud API key in ~/.bluemix/apiKey.json"
echo "You can login with the following command:"
echo "\n"
echo "ibmcloud login -a https://api.ng.bluemix.net --apikey @~/.bluemix/apiKey.json"
echo "\n"
echo "\n************************************"
echo " For the Kubernetes Dashboard use:"
echo " kubectl proxy --address='0.0.0.0'"
echo "************************************\n"
SHELL
######################################################################
# Postgres
######################################################################
config.vm.provision "docker" do |d|
d.pull_images "postgres:11-alpine"
d.run "postgres:11-alpine",
args: "--restart=always -d --name psql -h psql -p 5432:5432 -v /var/docker/postgresql:/data -e POSTGRES_PASSWORD=flaskrest02 -e POSTGRES_USER=flaskrest02 -e POSTGRES_DB=flaskrest02"
end
end