-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
133 lines (104 loc) · 3.92 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# The OS that will run our code
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
# Customizing memory. The VM will need at least 512MB
config.vm.customize ["modifyvm", :id, "--memory", 512]
config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
# In case the Rails app runs on port 3000, make it available on the host
config.vm.forward_port 3000, 3000
config.vm.forward_port 5432, 5432
#config.vm.forward_port 80, 8080
config.vm.provision :chef_solo do |chef|
# NOTE:
# This path should be created. Why? Because we want to enforce cookbooks repositories
# Just `mkdir cookbooks` inside the Catarse repository
# Install vagrant gem install librarian-chef
# Only this and cookbooks will be automatically installed
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apt"
# Include GCC and other utilities (compilation,etc)
chef.add_recipe "build-essential"
chef.add_recipe "git"
chef.add_recipe "curl"
chef.add_recipe "curl::devel"
chef.add_recipe "locale"
# Avoiding uft-8 problem
chef.add_recipe "set_locale"
# Virtual server X Frame Buffer
chef.add_recipe "xvfb"
chef.add_recipe "firefox"
# Image handling
chef.add_recipe "imagemagick"
chef.add_recipe "imagemagick::devel"
chef.add_recipe "imagemagick::rmagick"
# This recipe is necessary if you're working with Rails & needs a JS runtime
chef.add_recipe "nodejs"
# Make my terminal looks good
chef.add_recipe "oh_my_zsh"
# RVM for rubies management
chef.add_recipe "rvm::vagrant"
chef.add_recipe "rvm::system"
# PostgreSQL Because we Love it
chef.add_recipe "set_locale::postgres"
# Configuration:
# The JSON below is where we configure or modify our recipes attributes
# Every recipe has an 'attributes' folder, and these are accessible using the hash format
chef.json = {
# Installing The latest ruby version
rvm: {
default_ruby: 'ruby-1.9.3-p392',
# Installing multiple ruby versions
rubies: ['2.0.0-p0'],
upgrade: :latest,
# Gems that will be accessed globally
global_gems: [
{ name: :thin },
{ name: :bundler },
# Add heroku to make deployment easier
{ name: :heroku },
],
# Somehow needed for Vagrant
vagrant: {
system_chef_solo: '/opt/vagrant_ruby/bin/chef-solo'
}
},
# Configuring postgreSQL
# WARNING:
# If you're going to deploy using Chef, please Change all these configurations!
postgresql: {
listen_addresses: "*",
pg_hba: [
"host all all 0.0.0.0/0 md5",
"host all all ::1/0 md5",
],
users: [
{
username: "postgres",
password: "password",
superuser: true,
createdb: true,
login: true
}
],
},
# Making the terminal looks good with theming and assigning to the vagrant user
oh_my_zsh: {
users: [{
login: :vagrant,
plugins: %w{git bundler ruby vi rails}
}]
}
}
end
# Run the Rails project right on vagrant up
config.vm.provision :shell, inline: %q{cd /vagrant && export DISPLAY=:99}
config.vm.provision :shell, inline: %q{sudo /etc/init.d/xvfb start}
config.vm.provision :shell, inline: %q{sudo bash -c "echo 'UseDNS no' >> /etc/ssh/sshd_config"}
config.vm.provision :shell, inline: %q{cp /vagrant/config/database.sample.yml /vagrant/config/database.yml}
config.vm.provision :shell, inline: %q{cd /vagrant && bundle install}
config.vm.provision :shell, inline: %q{cd /vagrant && rake db:create db:migrate db:test:prepare db:seed}
config.vm.provision :shell, inline: %q{cd /vagrant && rails s -d}
end