Skip to content

Commit

Permalink
chore: add vagrant configuration with complete dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
jmickey committed Oct 8, 2021
1 parent ca14a16 commit 686b095
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ bin/

coverage.txt

.DS_Store
.DS_Store
.vagrant
100 changes: 100 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Copyright The reignite Authors

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"

config.ssh.forward_agent = true

config.vm.provider :virtualbox do |v|
# Enable nested virtualisation in VBox
v.customize ["modifyvm", :id, "--nested-hw-virt", "on"]

v.memory = 4096
v.cpus = 2
end

config.vm.provision "upgrade-packages", type: "shell", run: "once" do |sh|
sh.inline = <<~SHELL
#!/usr/bin/env bash
set -eux -o pipefail
apt update && apt upgrade -y
SHELL
end

config.vm.provision "install-basic-packages", type: "shell", run: "once" do |sh|
sh.inline = <<~SHELL
#!/usr/bin/env bash
set -eux -o pipefail
apt install -y \
make \
git \
gcc \
curl \
unzip \
containerd
SHELL
end

config.vm.provision "install-golang", type: "shell", run: "once" do |sh|
sh.env = {
'GO_VERSION': ENV['GO_VERSION'] || "1.17.1",
}
sh.inline = <<~SHELL
#!/usr/bin/env bash
set -eux -o pipefail
curl -fsSL "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar Cxz /usr/local
cat >> /etc/environment <<EOF
PATH=/usr/local/go/bin:$PATH
EOF
source /etc/environment
cat >> /etc/profile.d/sh.local <<EOF
GOPATH=\\$HOME/go
PATH=\\$GOPATH/bin:\\$PATH
export GOPATH PATH
EOF
source /etc/profile.d/sh.local
SHELL
end

config.vm.provision "configure-thinpool", type: "shell",
run: "once", path: "./hack/scripts/devpool.sh"

config.vm.provision "configure-containerd", type: "shell", run: "once" do |sh|
sh.inline = <<~SHELL
#!/usr/bin/env bash
set -eux -o pipefail
# ensure directories exist
mkdir -p /etc/containerd
mkdir -p /var/lib/containerd-dev/snapshotter/devmapper
mkdir -p /run/containerd-dev/
cp /vagrant/hack/scripts/example-config.toml /etc/containerd/config.toml
systemctl restart containerd
SHELL
end

config.vm.provision "install-firecracker", type: "shell", run: "once" do |sh|
sh.inline = <<~SHELL
curl -fsSL "https://github.com/weaveworks/reignite/files/7278467/firecracker_macvtap.zip" -o /tmp/firecracker-macvtap.zip
unzip /tmp/firecracker-macvtap.zip -d /usr/local/bin
SHELL
end

end
20 changes: 20 additions & 0 deletions hack/scripts/example-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version = 2

root = "/var/lib/containerd-dev"
state = "/run/containerd-dev"

[grpc]
address = "/run/containerd-dev/containerd.sock"

[metrics]
address = "127.0.0.1:1338"

[plugins]
[plugins."io.containerd.snapshotter.v1.devmapper"]
pool_name = "dev-thinpool"
root_path = "/var/lib/containerd-dev/snapshotter/devmapper"
base_image_size = "10GB"
discard_blocks = true

[debug]
level = "trace"

0 comments on commit 686b095

Please sign in to comment.