-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
61 lines (43 loc) · 1.82 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
$setup = <<SCRIPT
echo "Stopping and removing existing containers"
#stop and remove any existing containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
echo "Building from Dockerfiles"
# Build containers from Dockerfiles
docker build -t longie/redis /var/local/poc/dockerRedis
docker build -t longie/node /var/local/poc/dockerNode
echo "Running & linking containers"
# Run and link the containers
docker run -d -P --name redis longie/redis
docker run -d -P -p 9191:9191 -p 8181:8181 --name node --link redis:redis longie/node
SCRIPT
# Commands required to ensure correct docker containers
# are started when the vm is rebooted.
$start = <<SCRIPT
docker start redis
docker start node
SCRIPT
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure("2") do |config|
# Require a recent version of vagrant otherwise some have reported errors setting host names on boxes
Vagrant.require_version ">= 1.6.5"
# Expose Redis database settings via NodeJS app
config.vm.network "forwarded_port", guest: 9191, host: 9191
# Virtualbox customization
config.vm.provider :virtualbox do |virtualbox, override|
# Customize VM
virtualbox.customize ["modifyvm", :id, "--memory", "1024", "--cpus", "1", "--pae", "on", "--hwvirtex", "on", "--ioapic", "on", "--name", "SAP-Docker"]
end
# Ubuntu
config.vm.box = "precise64"
config.vm.box_url="http://files.vagrantup.com/precise64.box"
# Install latest docker
config.vm.provision "docker"
config.vm.synced_folder ".", "/var/local/poc" #, type: "nfs"
# Setup the containers, with caching enabled these will rebuild any changes since last build
config.vm.provision "shell", run: "always", inline: $setup
# Make sure the correct containers are running
# every time we start the VM.
config.vm.provision "shell", run: "always", inline: $start
end