From 1aae9362a7bec2ce67c62b6cba6cd8cccce774df Mon Sep 17 00:00:00 2001 From: Patrick Stephens Date: Mon, 8 Aug 2022 12:13:30 +0100 Subject: [PATCH] development: add Vagrantfile support and docs Signed-off-by: Patrick Stephens --- DEVELOPER_GUIDE.md | 16 ++++------------ Vagrantfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 Vagrantfile diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 5f1f4712d58..04d50f3c519 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -545,20 +545,12 @@ cmake ... make ``` -Be aware of any permissions issues with the filesystem on the VM vs the host. -You may prefer to build to an un-exposed filesystem: - -```shell -vagrant up -vagrant ssh -mkdir -p /tmp/build -cd /tmp/build -cmake ... /vagrant -make -``` - It also acts as a reference for the tooling required to be installed on a local PC if you want to build things. +The VM created by Vagrant uses `rsync` to synchronize the files with rather than directly mounting the local directory. +The reason is to handle any permission issues and isolate the underlying host filesystem. +Refer to the Vagrant documentation for syncing changes: + To enable the unit tests run: ```shell diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000000..7f74824cb34 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,43 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + # config.vm.box = "ubuntu/focal64" # Ubuntu 20.04 Focal Fossa (non CO-RE) + # config.vm.box = "ubuntu/hirsute64" # Ubuntu 21.04 Hirsute Hippo (CO-RE) + # config.vm.box = "ubuntu/impish64" # Ubuntu 21.10 Impish Indri (CO-RE) + config.vm.box = "ubuntu/jammy64" # Ubuntu 22.04 Jammy Jellyfish (CO-RE) + + config.ssh.extra_args = ["-t", "cd /vagrant; bash --login"] + + # Use rsync rather than mounting into the VM as triggers a few issues with permissions during build + config.vm.synced_folder ".", "/vagrant", type: "rsync" + + config.vm.provider "virtualbox" do |vb| + vb.gui = false + vb.memory = "2048" + end + + config.vm.provision "shell", inline: <<-SHELL + VAGRANT_HOME="/home/vagrant" + + apt-get update + apt-get install --yes apt-transport-https ca-certificates curl + + # https://github.com/fluent/fluent-bit/tree/master/packaging/distros/ubuntu + + # Main build + apt-get install --yes build-essential cmake dh-make git make openssl pkg-config tar + # Dependencies + apt-get install --yes libssl3 libssl-dev libsasl2-dev pkg-config libsystemd-dev zlib1g-dev libpq-dev postgresql-server-dev-all flex bison libyaml-dev libpq5 + + # Debug + apt-get install --yes gdb valgrind + + # From Unit Tests: + apt-get install --yes gcc-7 g++-7 clang-6.0 gcovr + + # For packaging potentially + apt-get install --yes docker.io + usermod -aG docker vagrant + SHELL +end