aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/codesearch/Vagrantfile
blob: 0407a57b5d85ebab8b8f9adaed26ef24cab4c8a2 (plain)
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
# -*- mode: ruby -*-
# -*- coding: utf-8 -*-

host_ip = "192.168.121.1"
synced_folder = "/vagrant"
houndd_bin = "${HOME}/go/bin/houndd"
houndd_config = "${HOME}/config.json"

$replace_dns = <<-SCRIPT
  HOST_IP="$1"
  rm -f /etc/resolv.conf # drop its dynamic management by systemd-resolved
  echo nameserver "$HOST_IP" | tee /etc/resolv.conf
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu1804"
  config.vm.synced_folder ".", synced_folder, type: "rsync", rsync__exclude: "Vagrantfile"
  config.vm.network "forwarded_port", guest: 6080, host: 6080
  config.vm.provision "replace_dns", type: :shell, run: "always", inline: $replace_dns, args: host_ip
  config.vm.provision "dependencies", type: :shell, inline: <<-SHELL
    export DEBIAN_FRONTEND=noninteractive
    apt-get update
    apt-get install --assume-yes --quiet golang tmux
  SHELL
  config.vm.provision "binaries", type: :shell, privileged: false, inline: <<-SHELL
    export GOPATH="${HOME}/go"
    go get -u github.com/hound-search/hound/cmds/...
  SHELL
  config.vm.provision "generate_config", type: :shell, privileged: false, inline: <<-SHELL
    python3 #{synced_folder}/create_config.py > #{houndd_config}
  SHELL
  config.vm.provision "run_codesearch", type: :shell, privileged: false, inline: <<-SHELL
    tmux new -d -s codesearch #{houndd_bin} -conf #{houndd_config}
  SHELL
end