Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: Caches bundler installs to speed up deployments
Gems are currently being installed in the release path. When a new release is
created, all the gems must be installed again. By caching the gems in the
shared folder we can speed up the deployments considerably.
  • Loading branch information
beirigo committed Aug 30, 2016
1 parent 58f840c commit baa0f44
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions libraries/helpers.rb
Expand Up @@ -58,9 +58,11 @@ def every_enabled_rds
end
end

def perform_bundle_install(release_path)
def perform_bundle_install(shared_path)
bundle_path = "#{shared_path}/vendor/bundle"

execute 'bundle_install' do
command '/usr/local/bin/bundle install --deployment --without development test'
command "/usr/local/bin/bundle install --deployment --without development test --path #{bundle_path}"
cwd release_path
end
end
Expand Down
1 change: 1 addition & 0 deletions recipes/configure.rb
Expand Up @@ -13,6 +13,7 @@
create_deploy_dir(application, File.join('shared', 'pids'))
create_deploy_dir(application, File.join('shared', 'scripts'))
create_deploy_dir(application, File.join('shared', 'sockets'))
create_deploy_dir(application, File.join('shared', 'vendor/bundle'))

databases = []
every_enabled_rds do |rds|
Expand Down
4 changes: 2 additions & 2 deletions recipes/deploy.rb
Expand Up @@ -52,7 +52,7 @@
migration_command(framework.out[:migration_command])
migrate framework.out[:migrate]
before_migrate do
perform_bundle_install(release_path)
perform_bundle_install(shared_path)

fire_hook(:deploy_before_migrate, context: self,
items: databases + [scm, framework, appserver, worker, webserver])
Expand All @@ -61,7 +61,7 @@
end

before_symlink do
perform_bundle_install(release_path) unless framework.out[:migrate]
perform_bundle_install(shared_path) unless framework.out[:migrate]

fire_hook(:deploy_before_symlink, context: self,
items: databases + [scm, framework, appserver, worker, webserver])
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/recipes/configure_spec.rb
Expand Up @@ -48,6 +48,10 @@
it 'creates shared/sockets' do
expect(chef_run).to create_directory("/srv/www/#{aws_opsworks_app['shortname']}/shared/sockets")
end

it 'creates shared/vendor/bundle' do
expect(chef_run).to create_directory("/srv/www/#{aws_opsworks_app['shortname']}/shared/vendor/bundle")
end
end

context 'Postgresql + Git + Unicorn + Nginx + Sidekiq' do
Expand Down

0 comments on commit baa0f44

Please sign in to comment.