-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathVagrantfile
126 lines (105 loc) · 4.07 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
Vagrant.configure("2") do |config|
config.vm.define "docker", primary: true do |app|
app.vm.box = "ubuntu/trusty64"
app.vm.box_check_update = false
app.vm.provider "virtualbox" do |vm|
vm.memory = 512
vm.cpus = 2
vm.name = "rmr"
end
# Publish application ports
{
5432 => 5432, # PostgreSQL 9.4
5433 => 5433, # PostgreSQL 9.5
5672 => 5672, # RabbitMQ
15672 => 15672, # RabbitMQ management
6379 => 6379, # Redis
}.each do |host, guest|
app.vm.network "forwarded_port", host: host, guest: guest
end
# build Docker images
app.vm.provision "docker" do |docker|
docker.build_image "/vagrant/etc/postgres/9.4", args: "--tag=redmadrobot/postgres:9.4"
docker.build_image "/vagrant/etc/postgres/9.5", args: "--tag=redmadrobot/postgres:9.5"
docker.build_image "/vagrant/etc/redis/sessions", args: "--tag=redmadrobot/redis:3-sessions"
end
# remove obsolete Docker images
app.vm.provision "shell",
inline: "docker images | sed 1d | grep '<none>' | awk '{print($3)}' | uniq | xargs docker rmi || true"
end
config.vm.define "postgres-9.4", autostart: false do |app|
# http://docs.vagrantup.com/v2/docker/configuration.html
app.vm.provider "docker" do |container|
container.name = "postgres-9.4"
container.force_host_vm = true
container.image = "redmadrobot/postgres:9.4"
container.ports = [
"5432:5432",
]
container.vagrant_machine = "docker"
container.vagrant_vagrantfile = __FILE__
container.volumes = [
"/data/postgres:/data/postgres",
]
container.env = {
PGDATA: "/data/postgres/9.4",
}
end
end
config.vm.define "postgres-9.5", autostart: false do |app|
# http://docs.vagrantup.com/v2/docker/configuration.html
app.vm.provider "docker" do |container|
container.name = "postgres-9.5"
container.force_host_vm = true
container.image = "redmadrobot/postgres:9.5"
container.ports = [
"5433:5432",
]
container.vagrant_machine = "docker"
container.vagrant_vagrantfile = __FILE__
container.volumes = [
"/data/postgres:/data/postgres",
]
container.env = {
PGDATA: "/data/postgres/9.5",
}
end
end
config.vm.define "rabbitmq", autostart: false do |app|
# http://docs.vagrantup.com/v2/docker/configuration.html
app.vm.provider "docker" do |container|
container.name = "rabbitmq"
container.force_host_vm = true
container.image = "rabbitmq:3-management"
container.ports = [
"5672:5672",
"15672:15672", # admin web interface
]
container.vagrant_machine = "docker"
container.vagrant_vagrantfile = __FILE__
container.volumes = [
"/data/rabbitmq:/var/lib/rabbitmq",
]
container.env = {
RABBITMQ_DEFAULT_USER: "rabbitmq",
RABBITMQ_DEFAULT_PASS: "rabbitmq",
}
end
end
config.vm.define "sessions", autostart: false do |app|
# http://docs.vagrantup.com/v2/docker/configuration.html
app.vm.provider "docker" do |container|
container.name = "sessions"
container.force_host_vm = true
container.image = "redmadrobot/redis:3-sessions"
container.ports = [
"6379:6379",
]
container.vagrant_machine = "docker"
container.vagrant_vagrantfile = __FILE__
container.volumes = [
"/data/redis:/data",
]
end
end
end