diff options
author | Colin Mitchell <colin@muffinlabs.com> | 2017-05-03 22:36:36 -0400 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-04 04:36:36 +0200 |
commit | 908b96a370d08bbf9c9418f24ac50636b3f76e82 (patch) | |
tree | c5d146fb6447fe34406ddaa29395aa540eebed30 /Vagrantfile | |
parent | 13c16b4e95c134d883b54e796e842c7f72cbbe21 (diff) |
Make vagrant HTTP port configurable (#2510)
Diffstat (limited to 'Vagrantfile')
-rw-r--r-- | Vagrantfile | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Vagrantfile b/Vagrantfile index d58ef78fd..eeab72904 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,8 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +ENV["PORT"] ||= "3000" + $provision = <<SCRIPT cd /vagrant # This is where the host folder/repo is mounted @@ -12,8 +14,8 @@ sudo apt-add-repository 'deb https://dl.yarnpkg.com/debian/ stable main' # Add repo for NodeJS curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - -# Add firewall rule to redirect 80 to 3000 and save -sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000 +# Add firewall rule to redirect 80 to PORT and save +sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port #{ENV["PORT"]} echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections sudo apt-get install iptables-persistent -y @@ -62,7 +64,7 @@ $start = <<SCRIPT cd /vagrant export $(cat ".env.vagrant" | xargs) -rails s -d -b 0.0.0.0 +rails s -d -b 0.0.0.0 -p #{ENV["PORT"]} SCRIPT @@ -105,7 +107,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end # Otherwise, you can access the site at http://localhost:3000 - config.vm.network :forwarded_port, guest: 80, host: 3000 + config.vm.network :forwarded_port, guest: 80, host: ENV["PORT"] # Full provisioning script, only runs on first 'vagrant up' or with 'vagrant provision' config.vm.provision :shell, inline: $provision, privileged: false |