Skip to content

Commit

Permalink
Update vagrantfile and bootstrap to work with ubuntu trusty
Browse files Browse the repository at this point in the history
  • Loading branch information
andersoncardoso committed Sep 11, 2016
1 parent 4258304 commit ef227e9
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 68 deletions.
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,9 @@ DEPENDENCIES
tinymce-rails-langs
uglifier (>= 1.3.0)
underscore-rails

RUBY VERSION
ruby 2.0.0p648

BUNDLED WITH
1.13.0
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Maps rebuild
[![Code Climate](https://codeclimate.com/github/it3s/meppit.png)](https://codeclimate.com/github/it3s/meppit)
[![Coverage Status](https://coveralls.io/repos/it3s/meppit/badge.png)](https://coveralls.io/r/it3s/meppit)

* Ruby version: 2.0.0
* Ruby version: 2.0.0 (p648)

### System dependencies:

* postgresql 9.3 (with postgis2.x and postgresql-contrib for hstore)
* postgresql 9.4 (with postgis2.1 and postgresql-contrib for hstore)
* redis
* you need to have a execjs runtime (i.e. Nodejs, rhyno, therubyracer)
* imagemagick
Expand All @@ -27,4 +27,7 @@ Maps rebuild

### Vagrant:

We recomend you to use vagrant. Just `vagrant up` and everything is set up.
We recomend you to use vagrant:
- `vagrant up`
- `vagrant ssh`
- `cd meppit; ./bootstrap.sh`
67 changes: 34 additions & 33 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu-1310"
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-1310-x64-virtualbox-nocm.box"

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network :forwarded_port, guest: 3000, host: 3000, auto_correct: true
config.vm.network :forwarded_port, guest: 3500, host: 3500, auto_correct: true
config.vm.network :forwarded_port, guest: 9292, host: 9292, auto_correct: true

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network :private_network, ip: "192.168.56.101"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider :virtualbox do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
#
# View the documentation for the provider you're using for more
# information on available options.
Vagrant.configure(2) do |config|

config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--memory", 2048]
vb.customize ["modifyvm", :id, "--cpus", 2]
end

config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.box = "ubuntu/trusty64"

config.vm.provision :shell, inline: <<-SHELL
if [ ! -f ~/.runonce ]
then
sudo apt-get install --reinstall -y language-pack-en
sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales
echo 'LC_ALL="en_US.UTF-8"' | sudo tee -a /etc/default/locale
echo 'LANG="en_US.UTF-8"' | sudo tee -a /etc/default/locale
# Link the repo
cd /home/vagrant/
ln -s /vagrant /home/vagrant/meppit
touch ~/.runonce
fi
SHELL

# config.vm.provision :shell, :path => "bootstrap.sh"


#-----------------Network
# config.vm.network :private_network, ip: "192.168.56.101"

# App server
config.vm.network :forwarded_port, guest: 3000, host: 3000, auto_correct: true
config.vm.network :forwarded_port, guest: 3500, host: 3500, auto_correct: true
end
82 changes: 54 additions & 28 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,54 +1,80 @@
#!/usr/bin/env bash

if [ ! -f ~/runonce ]
if [ ! -f ~/.runonce ]
then
# Update
apt-get update
apt-get upgrade -y
# ============================
echo "-- UPDATE"
sudo apt-get -y update
sudo apt-get -y upgrade

# ============================
# Install dependencies
apt-get install -y git ruby2.0 ruby2.0-dev redis-server libpq-dev nodejs libxslt1.1 imagemagick build-essential libtool checkinstall libjson0-dev libxml2-dev libproj-dev python2.7-dev swig libgeos-3.3.3 libgeos-dev gdal-bin libgdal1-1.9.0-grass libgdal1-dev
apt-get install --reinstall -y language-pack-en language-pack-pt
echo "-- SETUP DEPS"
sudo apt-get install -y curl vim build-essential libtool checkinstall python-pip python-dev gcc make sqlite3 libcurl4-openssl-dev ruby-dev libssl-dev openssl libreadline-dev git
sudo apt-get install -y redis-server libpq-dev nodejs libxslt1.1 imagemagick libjson0-dev libxml2-dev libproj-dev python2.7-dev swig libgeos-3.4.2 libgeos-dev gdal-bin libgdal1-1.10.1-grass libgdal1-dev
sudo apt-get install --reinstall -y language-pack-en language-pack-pt
git config --global color.ui true

# ============================
# setup rbenv
echo "-- SETUP RBENV"
git clone git://github.com/sstephenson/rbenv.git /home/vagrant/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> /home/vagrant/.bashrc
echo 'eval "$(rbenv init -)"' >> /home/vagrant/.bashrc
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

# setup ruby-build
echo "-- SETUP RUBY-BUILD"
git clone git://github.com/sstephenson/ruby-build.git /home/vagrant/.rbenv/plugins/ruby-build

# postgresql 9.3
echo "deb http://apt.postgresql.org/pub/repos/apt/ saucy-pgdg main" >> /etc/apt/sources.list.d/pgdg.list
apt-get install -y wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get upgrade -y
apt-get install -y postgresql-9.3 postgresql-contrib-9.3 postgresql-client-9.3 postgresql-server-dev-9.3 postgresql-9.3-postgis-2.1 postgresql-9.3-postgis-2.1-scripts
# setup ruby
echo "-- SETUP RUBY"
source /home/vagrant/.bashrc
rbenv install 2.0.0-p648
rbenv global 2.0.0-p648
rbenv rehash
gem install bundler

# ============================
# setup postgresql 9.4 and postgis 2.1
echo "-- SETUP POSTGRES"
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

sudo apt-get install -y postgresql-9.4 postgresql-server-dev-9.4 postgresql-contrib-9.4 postgresql-client-9.4 postgresql-9.4-postgis-2.1 postgresql-9.4-postgis-2.1-scripts

# Create postgres user
sudo -u postgres createuser -r -s -d vagrant
sudo -u postgres createdb vagrant -O vagrant
sudo -u postgres psql -c "ALTER USER vagrant WITH PASSWORD 'vagrant';"
sudo -u postgres psql -c "ALTER USER vagrant SUPERUSER;"

# Configure Meppit
# ============================
echo "-- LINK PROJECT"
cd /home/vagrant/
sudo -u vagrant ln -s /vagrant /home/vagrant/meppit
ln -s /vagrant /home/vagrant/meppit

cd meppit
if [ ! -f config/application.yml ]
then
sudo -u vagrant cp config/application.yml.sample config/application.yml
cp config/application.yml.sample config/application.yml
fi

if [ ! -f config/database.yml ]
then
sudo -u vagrant cp config/database.yml.sample config/database.yml
sudo -u vagrant sed -i -e 's/username: postgres/username: vagrant/g' config/database.yml
cp config/database.yml.sample config/database.yml
sed -i '' -e 's/username: postgres/username: vagrant/g' config/database.yml
fi
source /home/vagrant/.bashrc

# ============================
# Ruby dependencies
gem install bundler

# Setup
sudo su - vagrant -c "cd ~/meppit && bundle"
sudo su - vagrant -c "cd ~/meppit && bundle exec rake db:create db:migrate"
sudo su - vagrant -c "cd ~/meppit && bundle exec rake db:create db:migrate RAILS_ENV=test"
sudo su - vagrant -c "cd ~/meppit && bundle exec rspec"
echo "-- RUBY DEPS"
cd ~/meppit
bundle
bundle exec rake db:create db:migrate
bundle exec rake db:create db:migrate RAILS_ENV=test
bundle exec rspec

touch ~/runonce
touch ~/.runonce
fi
7 changes: 3 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "hstore"
enable_extension "uuid-ossp"
enable_extension "postgis"
enable_extension "hstore"
enable_extension "pg_trgm"
enable_extension "fuzzystrmatch"

Expand Down Expand Up @@ -117,8 +116,8 @@
t.text "tags", default: [], array: true
t.datetime "created_at"
t.datetime "updated_at"
t.json "additional_info"
t.spatial "location", limit: {:srid=>4326, :type=>"geometry"}
t.json "additional_info"
end

add_index "geo_data", ["location"], :name => "index_geo_data_on_location", :spatial => true
Expand Down Expand Up @@ -260,12 +259,12 @@
t.text "about_me"
t.hstore "contacts"
t.string "avatar"
t.spatial "location", limit: {:srid=>4326, :type=>"geometry"}
t.string "remember_me_token"
t.datetime "remember_me_token_expires_at"
t.text "interests", default: [], array: true
t.string "auth_token"
t.string "mail_notifications", default: "daily"
t.spatial "location", limit: {:srid=>4326, :type=>"geometry"}
end

add_index "users", ["activation_token"], :name => "index_users_on_activation_token"
Expand Down

0 comments on commit ef227e9

Please sign in to comment.