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

Commit

Permalink
fix(framework): added environment variables context to bundle install
Browse files Browse the repository at this point in the history
Fixes #167
  • Loading branch information
ajgon authored Jun 24, 2018
1 parent 6b3c058 commit fe01d45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions recipes/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
appserver = Drivers::Appserver::Factory.build(self, application)
worker = Drivers::Worker::Factory.build(self, application, databases: databases)
webserver = Drivers::Webserver::Factory.build(self, application)
bundle_env = source.class.adapter.to_s == 'Chef::Provider::Git' ? { 'GIT_SSH' => source.out[:ssh_wrapper] } : {}
env_vars = application['environment'].merge(framework.out[:deploy_environment] || {}).merge(
source.class.adapter.to_s == 'Chef::Provider::Git' ? { 'GIT_SSH' => source.out[:ssh_wrapper] } : {}
)

fire_hook(:before_deploy, items: databases + [source, framework, appserver, worker, webserver])

deploy application['shortname'] do
deploy_to deploy_dir(application)
user node['deployer']['user'] || 'root'
group www_group
environment application['environment'].merge(framework.out[:deploy_environment] || {})
environment env_vars

if globals(:rollback_on_error, application['shortname']).nil?
rollback_on_error node['defaults']['global']['rollback_on_error']
Expand Down Expand Up @@ -60,7 +62,7 @@
migration_command(framework.out[:migration_command]) if framework.out[:migration_command]
migrate framework.migrate?
before_migrate do
perform_bundle_install(shared_path, bundle_env)
perform_bundle_install(shared_path, env_vars)

fire_hook(
:deploy_before_migrate, context: self, items: databases + [source, framework, appserver, worker, webserver]
Expand All @@ -70,7 +72,7 @@
end

before_symlink do
perform_bundle_install(shared_path, bundle_env) unless framework.migrate?
perform_bundle_install(shared_path, env_vars) unless framework.migrate?

fire_hook(
:deploy_before_symlink, context: self, items: databases + [source, framework, appserver, worker, webserver]
Expand Down
4 changes: 3 additions & 1 deletion spec/unit/recipes/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
scm_provider: Chef::Provider::Git,
enable_submodules: false,
rollback_on_error: true,
environment: aws_opsworks_app['environment'].merge('RAILS_ENV' => 'staging'),
environment: aws_opsworks_app['environment'].merge(
'RAILS_ENV' => 'staging', 'GIT_SSH' => '/tmp/ssh-git-wrapper.sh'
),
ssh_wrapper: '/tmp/ssh-git-wrapper.sh',
symlinks: {
'system' => 'public/system',
Expand Down

0 comments on commit fe01d45

Please sign in to comment.