Skip to content

'deploy' deploys twice #28

@samnissen

Description

@samnissen

From config/deploy.rb

require 'mina/multistage'
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'

set :rvm_path, '$HOME/.rvm/bin/rvm'

task :remote_environment do
  invoke :'rvm:use', 'ruby-2.4'
end

task :'db:configure' do
  invoke :'rails:db_create'
  invoke :'rails:db_migrate'
  command "#{fetch(:rails)} db:seed"
end

From config/deploy/production.rb

set :domain, ENV['SOMEENVNAME']
set :deploy_to, ENV['SOMEOTHERENV']
set :repository, 'git@private.address:name/codebase.git'
set :branch, 'master'
set :term_mode, nil
set :rails_env, 'production'

task :deploy => :environment do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'db:configure'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'
    command %[sudo /bin/systemctl restart httpd.service]
  end
end

Running the appropriate setup steps and then mina production deploy (or staging, omitted for simplicity), produces

# ...
-----> Moving build to /path/to/deployment/releases/1
-----> Build finished
-----> Launching
       Connection to 1.2.3.4 closed.

-----> Updating the /path/to/deployment/current symlink
-----> Done. Deployed version 1
       Elapsed time: 206.62 seconds
-----> Creating a temporary build path # <= starting on version 2
-----> Using RVM environment "ruby-2.4"
       Using /home/rakuten-publishers/.rvm/gems/ruby-2.4.1
-----> Fetching new git commits
# ...

and

$ cd /path/to/deployment
$ ls releases/
1  2

Both with seemingly correct deployments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions