Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

gregwork commented Dec 17, 2012

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
You can’t perform that action at this time.