2015-08-17 06:37:14 +02:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
|
2021-09-14 01:36:17 +02:00
|
|
|
Vagrant.require_version ">= 2.2.6"
|
2015-08-17 06:37:14 +02:00
|
|
|
|
2021-09-14 01:36:17 +02:00
|
|
|
Vagrant.configure("2") do |config|
|
2015-08-18 02:05:53 +02:00
|
|
|
# The Zulip development environment runs on 9991 on the guest.
|
2016-07-07 23:47:59 +02:00
|
|
|
host_port = 9991
|
2017-09-14 21:10:14 +02:00
|
|
|
http_proxy = https_proxy = no_proxy = nil
|
2016-12-30 04:47:04 +01:00
|
|
|
host_ip_addr = "127.0.0.1"
|
2015-08-17 06:37:14 +02:00
|
|
|
|
2019-04-10 09:44:39 +02:00
|
|
|
# System settings for the virtual machine.
|
|
|
|
vm_num_cpus = "2"
|
|
|
|
vm_memory = "2048"
|
|
|
|
|
2019-05-29 03:58:11 +02:00
|
|
|
ubuntu_mirror = ""
|
2020-12-19 08:26:19 +01:00
|
|
|
vboxadd_version = nil
|
2019-05-29 03:58:11 +02:00
|
|
|
|
2015-08-17 06:37:14 +02:00
|
|
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
2019-08-09 02:33:50 +02:00
|
|
|
config.vm.synced_folder ".", "/srv/zulip"
|
2015-08-17 06:37:14 +02:00
|
|
|
|
2021-03-24 18:31:13 +01:00
|
|
|
vagrant_config_file = ENV["HOME"] + "/.zulip-vagrant-config"
|
2016-07-07 23:47:59 +02:00
|
|
|
if File.file?(vagrant_config_file)
|
|
|
|
IO.foreach(vagrant_config_file) do |line|
|
2016-04-09 15:06:07 +02:00
|
|
|
line.chomp!
|
|
|
|
key, value = line.split(nil, 2)
|
|
|
|
case key
|
2021-03-24 18:31:13 +01:00
|
|
|
when /^([#;]|$)/ # ignore comments
|
2016-04-09 15:06:07 +02:00
|
|
|
when "HTTP_PROXY"; http_proxy = value
|
|
|
|
when "HTTPS_PROXY"; https_proxy = value
|
|
|
|
when "NO_PROXY"; no_proxy = value
|
2016-07-07 23:47:59 +02:00
|
|
|
when "HOST_PORT"; host_port = value.to_i
|
2016-12-30 04:47:04 +01:00
|
|
|
when "HOST_IP_ADDR"; host_ip_addr = value
|
2019-04-10 09:44:39 +02:00
|
|
|
when "GUEST_CPUS"; vm_num_cpus = value
|
|
|
|
when "GUEST_MEMORY_MB"; vm_memory = value
|
2019-05-29 03:58:11 +02:00
|
|
|
when "UBUNTU_MIRROR"; ubuntu_mirror = value
|
2020-12-19 08:26:19 +01:00
|
|
|
when "VBOXADD_VERSION"; vboxadd_version = value
|
2016-04-09 15:06:07 +02:00
|
|
|
end
|
|
|
|
end
|
2016-07-07 23:47:59 +02:00
|
|
|
end
|
2016-04-09 15:06:07 +02:00
|
|
|
|
2016-07-07 23:47:59 +02:00
|
|
|
if Vagrant.has_plugin?("vagrant-proxyconf")
|
2017-09-14 21:10:14 +02:00
|
|
|
if !http_proxy.nil?
|
2016-07-07 23:47:59 +02:00
|
|
|
config.proxy.http = http_proxy
|
|
|
|
end
|
2017-09-14 21:10:14 +02:00
|
|
|
if !https_proxy.nil?
|
2016-07-07 23:47:59 +02:00
|
|
|
config.proxy.https = https_proxy
|
|
|
|
end
|
2017-09-14 21:10:14 +02:00
|
|
|
if !no_proxy.nil?
|
2016-07-07 23:47:59 +02:00
|
|
|
config.proxy.no_proxy = no_proxy
|
2016-04-09 15:06:07 +02:00
|
|
|
end
|
2017-09-14 21:10:14 +02:00
|
|
|
elsif !http_proxy.nil? or !https_proxy.nil?
|
|
|
|
# This prints twice due to https://github.com/hashicorp/vagrant/issues/7504
|
|
|
|
# We haven't figured out a workaround.
|
2021-03-24 18:31:13 +01:00
|
|
|
puts "You have specified value for proxy in ~/.zulip-vagrant-config file but did not " \
|
|
|
|
"install the vagrant-proxyconf plugin. To install it, run `vagrant plugin install " \
|
|
|
|
"vagrant-proxyconf` in a terminal. This error will appear twice."
|
2017-09-14 21:10:14 +02:00
|
|
|
exit
|
2016-04-09 15:06:07 +02:00
|
|
|
end
|
|
|
|
|
2017-09-14 21:10:14 +02:00
|
|
|
config.vm.network "forwarded_port", guest: 9991, host: host_port, host_ip: host_ip_addr
|
2018-04-25 21:16:08 +02:00
|
|
|
config.vm.network "forwarded_port", guest: 9994, host: host_port + 3, host_ip: host_ip_addr
|
2019-05-27 23:47:40 +02:00
|
|
|
# Specify Docker provider before VirtualBox provider so it's preferred.
|
|
|
|
config.vm.provider "docker" do |d, override|
|
|
|
|
d.build_dir = File.join(__dir__, "tools", "setup", "dev-vagrant-docker")
|
|
|
|
d.build_args = ["--build-arg", "VAGRANT_UID=#{Process.uid}"]
|
2019-05-29 03:58:11 +02:00
|
|
|
if !ubuntu_mirror.empty?
|
|
|
|
d.build_args += ["--build-arg", "UBUNTU_MIRROR=#{ubuntu_mirror}"]
|
|
|
|
end
|
2019-05-27 23:47:40 +02:00
|
|
|
d.has_ssh = true
|
|
|
|
d.create_args = ["--ulimit", "nofile=1024:65536"]
|
2016-01-10 01:31:37 +01:00
|
|
|
end
|
|
|
|
|
2015-08-17 19:18:40 +02:00
|
|
|
config.vm.provider "virtualbox" do |vb, override|
|
2020-06-10 19:34:36 +02:00
|
|
|
override.vm.box = "hashicorp/bionic64"
|
2016-07-21 03:39:54 +02:00
|
|
|
# It's possible we can get away with just 1.5GB; more testing needed
|
2019-04-10 09:44:39 +02:00
|
|
|
vb.memory = vm_memory
|
|
|
|
vb.cpus = vm_num_cpus
|
2020-12-19 08:26:19 +01:00
|
|
|
|
|
|
|
if !vboxadd_version.nil?
|
|
|
|
override.vbguest.installer = Class.new(VagrantVbguest::Installers::Ubuntu) do
|
|
|
|
define_method(:host_version) do |reload = false|
|
|
|
|
VagrantVbguest::Version(vboxadd_version)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
override.vbguest.allow_downgrade = true
|
|
|
|
override.vbguest.iso_path = "https://download.virtualbox.org/virtualbox/#{vboxadd_version}/VBoxGuestAdditions_#{vboxadd_version}.iso"
|
|
|
|
end
|
2015-08-17 06:37:14 +02:00
|
|
|
end
|
2015-08-17 20:14:52 +02:00
|
|
|
|
2021-01-20 14:55:11 +01:00
|
|
|
config.vm.provider "hyperv" do |h, override|
|
|
|
|
override.vm.box = "bento/ubuntu-18.04"
|
|
|
|
h.memory = vm_memory
|
|
|
|
h.maxmemory = vm_memory
|
|
|
|
h.cpus = vm_num_cpus
|
|
|
|
end
|
|
|
|
|
2020-08-11 07:23:39 +02:00
|
|
|
config.vm.provider "parallels" do |prl, override|
|
2021-03-24 18:31:13 +01:00
|
|
|
override.vm.box = "bento/ubuntu-18.04"
|
|
|
|
override.vm.box_version = "202005.21.0"
|
|
|
|
prl.memory = vm_memory
|
|
|
|
prl.cpus = vm_num_cpus
|
2020-08-11 07:23:39 +02:00
|
|
|
end
|
|
|
|
|
2015-08-19 04:14:50 +02:00
|
|
|
config.vm.provision "shell",
|
2017-01-14 11:19:26 +01:00
|
|
|
# We want provision to be run with the permissions of the vagrant user.
|
2015-08-19 04:14:50 +02:00
|
|
|
privileged: false,
|
2021-09-14 02:13:17 +02:00
|
|
|
path: "tools/setup/vagrant-provision",
|
|
|
|
env: { "UBUNTU_MIRROR" => ubuntu_mirror }
|
2015-08-17 06:37:14 +02:00
|
|
|
end
|