Skip to content

Commit c6e7f83

Browse files
committed
vagrant: Install docker and docker-compose via setup.sh
Without this a user needs to run vagrant more than once the first time they try this out, once to fetch the vagrant-docker-compose plugin and then again to actually run through. Why go through that when we already have code for install docker and docker-compose that we have to maintain seprately anyway and leads to a better first experience too? Another minor benefit is that we increase the code sharing between terraform and vagrant's setup.sh, which is nice. Signed-off-by: Manuel Mendez <[email protected]>
1 parent 088c345 commit c6e7f83

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

deploy/vagrant/Vagrantfile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
PROVISIONER_IP = "192.168.56.4"
55
MACHINE1_IP = "192.168.56.43"
66

7-
unless Vagrant.has_plugin?("vagrant-docker-compose")
8-
system("vagrant plugin install vagrant-docker-compose")
9-
puts "Dependencies installed, please try the command again."
10-
exit
11-
end
12-
137
Vagrant.configure("2") do |config|
148
config.vm.provider :libvirt do |libvirt|
159
libvirt.qemu_use_session = false
@@ -37,8 +31,6 @@ Vagrant.configure("2") do |config|
3731
override.vm.synced_folder "../compose/", "/vagrant/compose/", type: "rsync"
3832
end
3933

40-
provisioner.vm.provision :docker
41-
provisioner.vm.provision :docker_compose, compose_version: "1.29.2"
4234
provisioner.vm.provision :shell, path: "setup.sh", args: [PROVISIONER_IP, MACHINE1_IP]
4335
end
4436

deploy/vagrant/setup.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
#!/usr/bin/env bash
22

3+
install_docker() {
4+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
5+
add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
6+
update_apt
7+
apt-get install --no-install-recommends containerd.io docker-ce docker-ce-cli
8+
gpasswd -a vagrant docker
9+
}
10+
11+
install_docker_compose() {
12+
apt-get install --no-install-recommends python3-pip
13+
pip install docker-compose
14+
}
15+
16+
apt-get() {
17+
DEBIAN_FRONTEND=noninteractive command apt-get \
18+
--allow-change-held-packages \
19+
--allow-downgrades \
20+
--allow-remove-essential \
21+
--allow-unauthenticated \
22+
--option Dpkg::Options::=--force-confdef \
23+
--option Dpkg::Options::=--force-confold \
24+
--yes \
25+
"$@"
26+
}
27+
28+
update_apt() {
29+
apt-get update
30+
}
31+
332
setup_layer2_network() {
433
host_addr=$1
534
ip addr show dev eth1 | grep -q "$host_addr" && return 0
@@ -47,6 +76,10 @@ main() {
4776
local host_addr=$1
4877
local worker_addr=$2
4978

79+
update_apt
80+
install_docker
81+
install_docker_compose
82+
5083
setup_layer2_network "$host_addr"
5184

5285
setup_compose_env_overrides "$host_addr" "$worker_addr"

0 commit comments

Comments
 (0)