timwaters / mapwarper

free open source public map georeferencer, georectifier and warper
http://mapwarper.net
MIT License
196 stars 80 forks source link

Update ruby on Vagrant VM and related document #135

Open kamataryo opened 7 years ago

kamataryo commented 7 years ago

Related to #131 and maybe #104. This PR adopts rbenv the version switcher, updates ruby and make Vagrant setup easy.

timwaters commented 7 years ago

This is good, thank you. Is there any chance of using RVM instead of rbenv? It's what I use on the servers. It's almost identical it seems, though.

btw: I'm looking into updating this for ubuntu 16:04 which would probably require compiling mapserver (and maybe gdal) using a versioned ruby. ergh.

kamataryo commented 7 years ago

Thanks for the response.

OK, I will try to exchange them. RVM might be more simple to install than rbenv.

timwaters commented 6 years ago

Hello, I recently changed the vagrant file to try to work with Ubuntu 16.04. And I think it will break your work, sorry. I think the provision script needs fixing also in master. However for 16.04 it needs gdal and mapserver to be manually compiled, if we are using rvm. It only needs gdal compiled if we use the system ruby. mapserver is quick to compile, gdal takes some time.

However, the code should work the same with vagrant set to work with 14.04, and 14.04 is quicker to get started (no compilations) I think we might have to make two vagrant files / configs. What do you think?

timwaters commented 6 years ago

It's running on 16.04 on mapwarper.net and on my local dev machine. I think the Ruby version has been updated too - but it's not that different from 14.04. There was no code changes related to newer Ruby versions anyhow.

kamataryo commented 6 years ago

Cool! Thanks for the notice. I will try with Ubuntu 16.04. I think the vagrant developmental environment is enough with single Vagrantfile. Vagrant CLI seems not to have options to specify certain Vagrantfile, so several Vagrantfiles sometimes seems to be troublesome. How about to branch conditions with environmental variable when vagrant up ?

The Vagrantfile below should work with all commands vagrant up, UBUNTU_VERSION=16.04 vagrant up and UBUNTU_VERSION=14.04 vagrant up. Also we can provide 2 provisioners for both environment, 16.04 is preferable to be set as default.

# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  case ENV["UBUNTU_VERSION"]
    when "14.04" then
      BOX_NAME = "bento/ubuntu-14.04"
      PROVISION_FILE_NAME = "lib/vagrant/provision-14.04.sh"
    else
      BOX_NAME = "bento/ubuntu-16.04"
      PROVISION_FILE_NAME = "lib/vagrant/provision.sh"
  end

  config.vm.box = BOX_NAME
  config.vm.network :forwarded_port, guest: 3000, host: 3000
  config.vm.synced_folder ".", "/srv/mapwarper"
  config.vm.provision :shell, :path => PROVISION_FILE_NAME
  config.vm.provider :virtualbox do |v|
    v.memory = 4096
    v.cpus = 4
  end
end
kamataryo commented 6 years ago

The other idea is to provide official Map Warper Vagrant box, which includes GDAL and MapServer on Ubuntu 16.04. This seems to be a fastest way for developers to get vagrant environment.