Chef::Log.error '**********************************************'
Chef::Log.error '********Running heragu DEPLOY recipe 4********'
Chef::Log.error '**********************************************'

stack_config     = node.display_hash['normal']

Chef::Log.error node
Chef::Log.error stack_config

application '/srv/rails-app' do
  user 'vagrant'
  group 'vagrant'

  git do
    repository 'https://github.com/heragu/api-sample.git'
    revision 'master'
  end

  bundle_install do
    deployment true
    without %w{development test}
  end

  rails do
    migrate true
    database do
      adapter   'mysql2'
      encoding  'utf8'
      pool      5
      host      stack_config['rails']['database']['host']
      username  stack_config['rails']['database']['username']
      password  stack_config['rails']['database']['password']
    end
    secret_token stack_config['rails']['secret_token']
  end

  unicorn do
    port 8010
  end
end
