4

I am trying to deploy my application using capistrano. But I want to deploy my application to multiple paths of the same server.For example If for the first run I want to deploy it to below path

set :deploy_to, '/home/a/some_path/

Once completed the first one it should run for the second path that will be

 set :deploy_to, '/home/b/some_path/

and so on. Any suggestions how can I achieve this? Right now my single path deployment path is working AOK.

Arihant Godha
  • 2,339
  • 2
  • 26
  • 50

2 Answers2

4

In your config file:

set :deploy_to, ENV["DEPLOY_PATH"]

Then, to deploy, run the command setting the DEPLOY_PATH variable:

DEPLOY_PATH="my/path" cap production deploy
sjaime
  • 1,480
  • 9
  • 16
0

Using capistrano 3.8.2, I monkeypatched lib/capistrano/dsl/paths.rb in my deploy.rb, but then I found that I needed more work to get git wrapper set up right when there where different deploy users. The result is at: https://gist.github.com/mcr/49e8c7034658120013c1fe49da77c2ac

But, I'm leaving the essence of the content here:

module Capistrano
  module DSL
    module Paths
      def deploy_to
        dir = @host.properties.fetch(:deploy_to) || fetch(:deploy_to)
        puts "For #{@host.hostname} deploy_to: #{dir}"
        dir
      end
    end
  end
end

(You can take the puts out, and shorten it to a one-liner, but I found the extra debug useful)

One then does:

server "server.client1.example.com", user: "client1", roles: %w{app db web}, deploy_to: '/client1/app/foobar'
server "server.client2.example.com", user: "client2", roles: %w{app db web}, deploy_to: '/client2/app/foobar'

where server.client1.example.com and server.client2.example.com are CNAMEs or duplicate A/AAAA records for the same server. This also isolates the question of where each client is to DNS.

mcr
  • 4,615
  • 2
  • 31
  • 30
  • While the above worked, it proved in the end to be inadequate, and I've forked capistrano (and capistrano-bundler) to try to solve the problem fully. – mcr Oct 25 '17 at 16:13