简体   繁体   中英

Capistrano deploy with two Git repositories

Here's my easy deploy script for my Ruby project.

set :application, "data"

set :repo_url, "git@github-data:MyCompany/api_data.git"

set :deploy_to, '/var/www/data'

append :linked_files, "config/secrets.yml"
append :linked_dirs, "log"

namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end
end

This works fine but I need to add an additional repo and have that deploy to a subdirectory of the main project. I've tried a few things so far without success. Thanks for any help

Cap 3.8.2

Given it's probably a capistrano limitation I see two possible approaches offhand (there are definatly more)

  • Make the sub-project a gem and include it that way
  • Use something like Fabric which while python code is more of an iterative scripted deploy tool

Expanding my comment into an answer.

Another option is to deploy the two repositories independently to different folders and use linked_dirs and symlinks to connect the two. I use this method all the time.

Let's say that the release path for your app is $APP_PATH and the release path for your secondary repo is $OTHER_APP_PATH . Let's also assume for the example, that you need the secondary repo to show up at lib/myapp in your app.

I would start by deploying your secondary app to $OTHER_APP_PATH on your server.

Then add append :linked_dirs, 'lib/myapp' to your app's deploy.rb config. When you deploy, you should have an empty folder at $APP_PATH/shared/lib/myapp which is symlinked to from $APP_PATH/current/lib/myapp . Delete that folder ( rmdir $APP_PATH/shared/lib/myapp ) and replace it with a symlink to the current directory of your secondary app ( ln -s $OTHER_APP_PATH/current $APP_PATH/shared/lib/myapp ).

Now the contents of your secondary app should show up in your primary app's lib/myapp folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM