Skip to content

Instantly share code, notes, and snippets.

@lusis
Created December 17, 2012 14:55
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lusis/4318860 to your computer and use it in GitHub Desktop.
Save lusis/4318860 to your computer and use it in GitHub Desktop.
if ENV['ES_CACHE']
config.vm.provision :shell do |shell|
shell.inline = "apt-get update; apt-get install -y apt-cacher-ng bindfs; service apt-cacher-ng stop; bindfs --mirror=apt-cacher-ng:@apt-cacher-ng /vagrant/cache /var/cache/apt-cacher-ng; echo 'Acquire::http { Proxy \"http://127.0.0.1:3142\"; };' > /etc/apt/apt.conf.d/01proxy; echo 'Acquire::https::Proxy::apt.repo.enstratus.com \"DIRECT\";' >> /etc/apt/apt.conf.d/01proxy; service apt-cacher-ng start"
end
end
@gregwork
Copy link

Try this for an easier option; it needs much less magic inside the VM.

if ENV['ES_CACHE']
  puts "Shared cache enabled"
  FileUtils.mkdir_p(File.join("apt","partial")) unless Dir.exists?(File.join("apt", "partial"))
  config.vm.share_folder("apt", "/var/cache/apt/archives", "apt")
end

As in your example, the first run sucks while the cache is populated; subsequent vagrant up's are fast. Also works with multi-vm environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment