0
votes

When trying to deploy a Rails app to a production server with Capistrano, it doesn't seem to recognize my project as being a git repo, despite me having cloned the project directly from GitHub.

THE GIT LOG:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

CAP LOG:

$ cap production deploy

    triggering load callbacks
  * 2016-06-01 16:30:26 executing `production'
    triggering start callbacks for `deploy'
  * 2016-06-01 16:30:26 executing `multistage:ensure'
  * 2016-06-01 16:30:26 executing `deploy'
  * 2016-06-01 16:30:26 executing `deploy:update'
 ** transaction: start
  * 2016-06-01 16:30:26 executing `deploy:update_code'
    executing locally: "git ls-remote [email protected]:mitigation/mpm.git r1"
    command finished in 662ms
  * refreshing local cache to revision 8c86d067abde1464f88902566324a99e22cd3147 at /var/folders/xs/5qz1glwj30v51rwpxhyclw880000gn/T/mpm
    executing locally: cd /var/folders/xs/5qz1glwj30v51rwpxhyclw880000gn/T/mpm && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 8c86d067abde1464f88902566324a99e22cd3147 && git clean -q -d -x -f

fatal: Not a git repository (or any of the parent directories): .git

command finished in 13ms
shell command failed with return code pid 52560 exit 128

Here's my Capfile:

load 'deploy'
load 'deploy/assets'
load 'config/deploy' 

Here's my DEPLOY.RB:

require 'soprano'

require 'bundler/capistrano'

require 'capistrano/ext/multistage'

require 'whenever/capistrano'

require 'leipreachan/capistrano2'

set :default_environment, {
  'PATH' => '/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:$PATH'
}


set :web_server, :nginx
set :keep_releases, 3

set :repository, '[email protected]:mitigation/mpm.git'

set :deploy_via, :copy
set :copy_exclude, %w(.git .idea .yardoc tmp log .DS_Store doc/* public/uploads.tar db/*.sql vendor/cache)
set :copy_cache, true

set :bundle_without, [:development, :test]
set :bundle_flags, '--deployment --binstubs'

set :user, 'deploy'

before 'deploy:setup', :db
after 'deploy:create_symlink', 'utils:version'
after 'deploy:update_code', 'db:symlink'

#For troubleshooting only
namespace :deploy do
  task :update_code, :except => { :no_release => true } do
    #on_rollback { run "rm -rf #{release_path}; true" }
    strategy.deploy!
    finalize_update
  end
end
1
I bet its the exluding of .git on your copy_exclude. It's copying to a temp dir perhaps, but not getting .git and that leaves it as no longer a repo. - Kevin
Could you elaborate a little more? I tried removing .git from the copy_exclude, but it still throws the same error. How would I go about fixing that? - Dylan Klett

1 Answers

0
votes

During deploys to various environments, capistrano3 creates a directory tree and puts the git information in a folder called repo_path. You'd have to travel inside that directory on your production server and "$git log" would work indicated its a .git repo

You also shouldn't need .git in your copy_exclude.

Try running through the capistrano3 set up process all over again with your app for different environments.