Vagrantfile: Add option for setting the port used on the host.

This makes it easier to (for example) run a Zulip development
environment on a host machine and sometimes run a Vagrant guest
inside.
This commit is contained in:
Tim Abbott 2016-07-07 14:47:59 -07:00
parent 3dee8a3dcb
commit 367f6e5bf7
2 changed files with 28 additions and 17 deletions

View File

@ -841,13 +841,22 @@ it (with the appropriate values in it for your proxy):
HTTP_PROXY http://proxy_host:port
HTTPS_PROXY http://proxy_host:port
NO_PROXY localhost,127.0.0.1,.example.com
```
Now run `vagrant up` in your terminal to install the development
server. If you ran `vagrant up` before and failed, you'll need to run
`vagrant destroy` first to clean up the failed installation.
You can also change the port on the host machine that Vagrant uses by
adding to your `~/.zulip-vagrant-config` file. E.g. if you set:
```
HOST_PORT 9971
```
(and halt and restart the Vagrant guest), then you would visit
http://localhost:9971/ to connect to your development server.
Installing on Ubuntu 14.04 Trusty without Vagrant
----------------------------------
Start by cloning this repository: `git clone

16
Vagrantfile vendored
View File

@ -13,16 +13,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "fgrehm/trusty64-lxc"
# The Zulip development environment runs on 9991 on the guest.
config.vm.network "forwarded_port", guest: 9991, host: 9991, host_ip: "127.0.0.1"
host_port = 9991
http_proxy = https_proxy = no_proxy = ""
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/srv/zulip"
proxy_config_file = ENV['HOME'] + "/.zulip-vagrant-config"
if File.file?(proxy_config_file)
http_proxy = https_proxy = no_proxy = ""
IO.foreach(proxy_config_file) do |line|
vagrant_config_file = ENV['HOME'] + "/.zulip-vagrant-config"
if File.file?(vagrant_config_file)
IO.foreach(vagrant_config_file) do |line|
line.chomp!
key, value = line.split(nil, 2)
case key
@ -30,8 +29,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
when "HTTP_PROXY"; http_proxy = value
when "HTTPS_PROXY"; https_proxy = value
when "NO_PROXY"; no_proxy = value
when "HOST_PORT"; host_port = value.to_i
end
end
end
config.vm.network "forwarded_port", guest: 9991, host: host_port, host_ip: "127.0.0.1"
if Vagrant.has_plugin?("vagrant-proxyconf")
if http_proxy != ""
@ -44,7 +47,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.proxy.no_proxy = no_proxy
end
end
end
# Specify LXC provider before VirtualBox provider so it's preferred.
config.vm.provider "lxc" do |lxc|