7 VM_STORAGE_POOL = "default"
10 # Dockerfile to analyse
11 DOCKER_FILE = ENV["DOCKER_FILE_ANALYSE"] || "Dockerfile.sample"
12 DOCKER_FILE_PATH = "/home/vagrant/ternvenv/Dockerfile"
13 # Docker image to analyse (in form of "debian:latest").
14 # Takes precedence over DOCKER_FILE
15 DOCKER_IMAGE = ENV['DOCKER_IMAGE_ANALYSE']
17 $install_docker= <<-SCRIPT
19 apt-get install --yes \
24 software-properties-common
25 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
27 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
31 apt-get install --yes \
32 docker-ce docker-ce-cli containerd.io
34 usermod -a -G docker $USER
37 $install_python = <<-SCRIPT
39 apt-get install --yes \
40 python3.8 libpython3.8-dev python3-pip python3.8-venv python3-setuptools\
42 attr bzip2 xz-utils zlib1g libxml2-dev libxslt1-dev \
43 findutils git gnupg2 tar util-linux
44 pip3 install --upgrade pip
47 $install_tern = <<-SCRIPT
49 python3 -m venv ternvenv
52 pip3 install --upgrade pip
53 pip3 install --no-cache-dir tern scancode-toolkit[full]
56 Vagrant.configure("2") do |config|
57 config.vm.box = "generic/ubuntu2004"
58 config.vm.hostname = "vagrant"
60 config.vm.provider :virtualbox do |v|
61 v.name = config.vm.hostname
66 config.vm.provider :libvirt do |v|
69 v.machine_virtual_size = VM_DISK
70 v.storage_pool_name = VM_STORAGE_POOL
73 config.vm.synced_folder '.', '/vagrant', disabled: true
75 config.vm.provision "install_docker", type: "shell" do |s|
77 s.env = {"DEBIAN_FRONTEND" => "noninteractive", "USER":VM_USER}
78 s.inline = $install_docker
82 config.vm.provision "install_python", type: "shell" do |s|
84 s.env = {"DEBIAN_FRONTEND" => "noninteractive"}
85 s.inline = $install_python
88 config.vm.provision "install_tern", type: "shell" do |s|
90 s.env = {"USER":VM_USER}
91 s.inline = $install_tern
94 # Add the Dockerfile for analysis to the Vagrant box
95 config.vm.provision "file", source: DOCKER_FILE, destination: DOCKER_FILE_PATH
97 config.vm.provision "license_analysis", type: "shell" do |s|
99 s.env = {"IMAGE":DOCKER_IMAGE, "FILE":DOCKER_FILE_PATH}
100 s.path = "tools/analysis.sh"