Skip to content

Instantly share code, notes, and snippets.

@crhan
Last active January 1, 2016 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crhan/8159771 to your computer and use it in GitHub Desktop.
Save crhan/8159771 to your computer and use it in GitHub Desktop.
deploy rails app to remote server, which has a limited internet access.
# config/deploy.rb
namespace :deploy do
desc "check local vendor/cache"
task :bundled_package do
run_locally do
unless test "[[ -d #{File.expand_path("../../vendor/cache", __FILE__)} ]]"
error "please `bundle package --all` first!"
raise StandardError
end
end
end
desc "upload vendor/cache for local gem install"
task :upload_vendor_cache do
on roles(:app) do
upload! File.expand_path("../../vendor/cache", __FILE__),
"#{shared_path}/vendor",
recursive: true
end
end
end
# config/deploy/production.rb
# link vendor/cache
set :linked_dirs, fetch(:linked_dirs, []).push("vendor/cache")
# check local vendor/cache first
before "deploy:starting", "deploy:bundled_package"
# upload cache to remote
before "bundler:install", "deploy:upload_vendor_cache"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment