Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update Vagrant config: new lucid32, apt cache, memory override.

* Use latest "lucid32" as base box, which has a special Ruby.
* Create and use a local cache for storing downloaded apt files.
* Allow user to override memory allocated to VM.
  • Loading branch information...
commit 19c3e16f76bc90234c89b4c3a0d9b46858d223d4 1 parent 67e4b1b
@igal igal authored
View
4 VAGRANT.md
@@ -87,6 +87,10 @@ Below are the supported overrides:
ADDRESS = "33.33.31.13"
+* Set the amount of memory to dedicate to the virtual machine to 512 megabytes. The appropriate amount will depend on how much memory you have available versus how much processes within the virtual machine need. In general, running `bundler` or `gem` in the virtual machine will require at least 512 megabytes:
+
+ MEMORY = 512
+
### Provisioning
You can customize your virtual machine by creating a `vagrant/cookbooks/vagrant/recipes/local.rb` file. This file is local to your computer and should not be added to revision control.
View
13 Vagrantfile
@@ -12,10 +12,10 @@ Vagrant::Config.run do |config|
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
- config.vm.box_url = "lucid32"
+ config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
# Every Vagrant virtual environment requires a box to build off of.
- config.vm.box = "citizenry"
+ config.vm.box = "lucid32"
# Assign this VM to a host only network IP, allowing you to access it
# via the IP.
@@ -33,9 +33,16 @@ Vagrant::Config.run do |config|
# folder, and the third is the path on the host to the actual folder.
config.vm.share_folder "vagrant", "/vagrant", ".", :nfs => defined?(NFS) ? NFS : false
+ # Share a folder with the guest VM for storing downloaded packages. This
+ # makes rebuilding VMs faster by only downloading packages if needed.
+ require "fileutils"
+ apt_cache = "tmp/vagrant_apt_cache"
+ FileUtils.mkdir_p("#{apt_cache}/archives/partial")
+ config.vm.share_folder "vagrant-apt-cache", "/var/cache/apt", apt_cache, :nfs => defined?(NFS) ? NFS : false
+
# Use more memory so badly-designed programs like Bundler can work.
config.vm.customize do |vm|
- vm.memory_size = 512
+ vm.memory_size = defined?(MEMORY) ? MEMORY : 512
end
# Enable provisioning with chef solo, specifying a cookbooks path (relative
View
30 vagrant/cookbooks/vagrant/recipes/default.rb
@@ -17,20 +17,34 @@
end
end
-# Add gems to PATH
+# Remove obsolete file
file "/etc/profile.d/rubygems1.8.sh" do
- content "PATH=/usr/lib/ruby/gems/1.8/bin:$PATH"
+ action :delete
+end
+
+# Add gems to PATH, use "zz-" prefix to ensure this runs after box's "vagrantruby.sh".
+file "/etc/profile.d/zz-rubygems1.8.sh" do
+ content "export PATH=`gem env path`:$PATH"
+end
+
+# Remove conflicting packages
+for name in %w[irb ruby-dev]
+ package name do
+ action :remove
+ end
end
# Install packages
-for name in %w[nfs-common git-core screen tmux elinks build-essential ruby-dev irb libcurl4-openssl-dev libsqlite3-dev mysql-server libmysqlclient-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev sphinxsearch imagemagick]
+for name in %w[nfs-common git-core screen tmux elinks build-essential libcurl4-openssl-dev libsqlite3-dev mysql-server libmysqlclient-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev sphinxsearch imagemagick]
package name
end
# Install gems
-for name in %w[bundler]
- gem_package name
-end
+gem_package "bundler"
+gem_package "rake"
+
+# Fix permissions on homedir
+execute "chown -R #{USER}:#{USER} ~#{USER}"
# Run the contents of the "vagrant/cookbooks/vagrant/recipes/local.rb" file if present. This optional file can contain additional provisioning logic that shouldn't be part of the global setup. For example, if you're using the "Gemfile.local" to install special gems, you'd use this "local.rb" to install their dependencies.
local_recipe = File.join(File.dirname(__FILE__), "local.rb")
@@ -54,11 +68,11 @@
# Install bundle
execute "install-bundle" do
cwd APPDIR
- command "su #{USER} -c 'bundle check || bundle --local || bundle'"
+ command "su vagrant -l -c 'bundle check || bundle --local || bundle'"
end
# Setup database
execute "setup-db" do
cwd APPDIR
- command "su #{USER} -c 'bundle exec rake db:create:all db:migrate db:test:prepare'"
+ command "su vagrant -l -c 'bundle exec rake db:create:all db:migrate db:test:prepare'"
end
Please sign in to comment.
Something went wrong with that request. Please try again.