{"id":13685564,"url":"https://github.com/sonots/capistrano-bundle_rsync","last_synced_at":"2025-05-16T07:03:27.447Z","repository":{"id":59151839,"uuid":"21615080","full_name":"sonots/capistrano-bundle_rsync","owner":"sonots","description":"Deploy an application and bundled gems via rsync ","archived":false,"fork":false,"pushed_at":"2025-03-19T04:28:17.000Z","size":113,"stargazers_count":71,"open_issues_count":0,"forks_count":27,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-13T19:06:10.313Z","etag":null,"topics":["capistrano","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sonots.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-07-08T14:09:16.000Z","updated_at":"2025-03-19T04:28:19.000Z","dependencies_parsed_at":"2025-04-13T06:21:50.813Z","dependency_job_id":"f20d5ce7-abdf-4b77-b00b-3431fd7d3331","html_url":"https://github.com/sonots/capistrano-bundle_rsync","commit_stats":{"total_commits":85,"total_committers":14,"mean_commits":6.071428571428571,"dds":0.3058823529411765,"last_synced_commit":"bee5e5c0376e2b2808aebbed7d3106d5d0fd61a6"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonots%2Fcapistrano-bundle_rsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonots%2Fcapistrano-bundle_rsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonots%2Fcapistrano-bundle_rsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonots%2Fcapistrano-bundle_rsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sonots","download_url":"https://codeload.github.com/sonots/capistrano-bundle_rsync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485029,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capistrano","ruby"],"created_at":"2024-08-02T14:00:53.727Z","updated_at":"2025-05-16T07:03:27.370Z","avatar_url":"https://github.com/sonots.png","language":"Ruby","readme":"# Capistrano::BundleRsync for Capistrano v3\n\nDeploy an application and bundled gems via rsync\n\n## What is this for?\n\nCapistrano::BundleRsync builds (bundle) gems only once on a deploy machine and transfers gems to your production machines via rsync, which saves you from building gems on each your production machine. \n\nAlso saves you from having to install Git and Build Tools on your production machine.\n\n## How it works\n\nCapistrano::BundleRsync works as followings:\n\n1. Do `git clone --mirror URL .local_repo/mirror` on a deploy (local) machine.\n2. Extract a branch by `git archive {branch}` to `.local_repo/releases/{datetime}`\n3. Do `bundle --without development test --path .local_repo/bundle` on a deploy (local) machine.\n4. Deploy the `release` directory to remote machines by `rsync`. \n5. Deploy the `bundle` directory to remote machines by `rsync`.\n\n## Prerequisites\n\nThe deploy machine and remote machines must be on same architectures (i386, x86\\_64) because\nC exntension gems are built on the deploy machine and transfered by rsync. \n\nRequiremens on remote machines:\n\n1. rbenv (rvm should work, but not verified)\n2. ruby\n\nRequirements on a deploy machine:\n\n1. rbenv (rvm should work, but not verified)\n2. git\n3. Build Tools required to build C exntension gems (like gcc).\n4. A ruby to execute capistrano (you may use the ruby of 5.)\n5. The same ruby used at your remote machines\n6. A ssh key to login to your remote machines via ssh (Passowrd authentication is not supported)\n\nNotice that it is not required to have Git and Build Tools on each remote machine. \n\n## Configuration\n\nSet Capistrano variables with `set name, value`.\n\nName          | Default | Description\n--------------|---------|------------\nrepo_url      | `.` | The path or URL to a Git repository to clone from.  \nrepo_tree      | nil | Specify the subtree path of the repository to deploy.\nbranch        | `master` | The Git branch to checkout.  \nssh_options   | `{}`  | Configuration of ssh :user and :keys.\nkeep\\_releases | 5 | The number of releases to keep.\nscm | nil | Must be `bundle_rsync` to use capistrano-bundle_rsync.\nbundle_rsync_scm | `git` | SCM Strategy inside `bundle_rsync`. `git`, `local_git`, or `git_turbo` can be specified.\nbundle_rsync_local_base_path   | `$(pwd)/.local_repo` | The base directory to clone repository\nbundle_rsync_local_mirror_path | `#{base_path}/mirror\"` | Path where to mirror your repository\nbundle_rsync_local_releases_path | `\"#{base_path}/releases\"` | The releases base directory to checkout your repository\nbundle_rsync_local_release_path | `\"#{releases_path}/#{datetime}\"` | The full path directory to checkout your repository. If you specify this, `keep_releases` for local releases path is disabled because `datetime` directories are no longer created. This parameter is set as `repo_url` in the case of `local_git` as default.\nbundle_rsync_local_bundle_path | `\"#{base_path}/bundle\"` | Path where to bundle install gems.\nbundle_rsync_ssh_options | `ssh_options` | Configuration of ssh for rsync. Default uses the value of `ssh_options`\nbundle_rsync_keep_releases | `keep_releases` | The number of releases to keep on .local_repo\nbundle_rsync_max_parallels | number of hosts | Number of concurrency. The default is the number of hosts to deploy.\nbundle_rsync_rsync_bwlimit | nil | Configuration of rsync --bwlimit (KBPS) option. Not Avabile if `bundle_rsync_rsync_options` is specified.\nbundle_rsync_rsync_options | `-az --delete` | Configuration of rsync options.\nbundle_rsync_config_files | `nil` | Additional files to rsync. Specified files are copied into `config` directory.\nbundle_rsync_shared_dirs | `nil` | Additional directories to rsync. Specified directories are copied into `shared` directory.\nbundle_rsync_app_path | `.` | A relative app path from local `bundle_rsync_local_release_path` and from remote `release_path`. `bundle` commands are executed here, and directories like `.bundle/config` and `config` will be located in this directory.\nbundle_rsync_skip_bundle | false | (Secret option) Do not `bundle` and rsync bundle.\nbundle_rsync_bundle_install_jobs | `nil` | Configuration of bundle install with --jobs option.\nbundle_rsync_bundle_install_standalone | `nil` | bundle install with --standalone option. Set one of `true`, `false`, an `Array` of groups, or a white space separated `String`.\nbundle_rsync_bundle_without | `[:development, :test]` | Configuration of bundle install with --without option.\n\n### BundleRsync SCM Strategies\n\n* git\n  * Original Strategy Using Git\n* local_git\n  * Directly Rsync Local (Non-Bare) Git Directory at `repo_url` Path to Remote Release Path\n* git_turbo\n  * Super-Fast Deployment Utilizing Git Worktree, Hardlink, and Rsync\n\n## Task Orders\n\n```\n$ cap stage deploy --trace | grep Execute\n** Execute bundle_rsync:check\n** Execute bundle_rsync:clone\n** Execute bundle_rsync:update\n** Execute bundle_rsync:create_release\n** Execute bundle_rsync:bundler:install\n** Execute bundle_rsync:rsync_release\n** Execute bundle_rsync:rsync_shared\n** Execute bundle_rsync:bundler:rsync\n** Execute bundle_rsync:clean_release\n** Execute bundle_rsync:set_current_revision\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'capistrano-bundle_rsync'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install capistrano-bundle_rsync\n\n## Usage\n\nAdd followings to your Gemfile (capistrano-rvm should work, but not verified):\n\n```ruby\ngem 'capistrano'\ngem 'capistrano-rbenv'\ngem 'capistrano-bundle_rsync'\n```\n\nRun `bundle exec cap install`. \n\n```bash\n$ bundle\n$ bundle exec cap install\n```\n\nThis creates the following files:\n\n```\n├── Capfile\n├── config\n│   ├── deploy\n│   │   ├── production.rb\n│   │   └── staging.rb\n│   └── deploy.rb\n└── lib\n    └── capistrano\n            └── tasks\n```\n\nTo create different stages:\n\n```bash\n$ bundle exec cap install STAGES=localhost,sandbox,qa,production\n```\n\nEdit Capfile:\n\n```ruby\n# Load DSL and Setup Up Stages\nrequire 'capistrano/setup'\n\n# Includes default deployment tasks\nrequire 'capistrano/deploy'\n\n# Includes tasks from other gems included in your Gemfile\nrequire 'capistrano/rbenv'\n\n# capistrano-3.3.3 - 3.6.1\nrequire 'capistrano/bundle_rsync'\n\n# capistrano-3.7+\nrequire 'capistrano/bundle_rsync/plugin'\ninstall_plugin Capistrano::BundleRsync::Plugin\n\n# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.\nDir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }\n```\n\nEdit `config/deploy/localhost.rb` as followings for example:\n\n```ruby\nset :branch, ENV['BRANCH'] || 'master'\nset :rbenv_type, :user\nset :linked_dirs, %w(log tmp/pids tmp/cache tmp/sockets vendor/bundle tmp/run)\nset :keep_releases, 5\nset :scm, :bundle_rsync # Need this when run with capistrano-3.3.3 - 3.6.1\nset :bundle_rsync_max_parallels, ENV['PARA']\nset :bundle_rsync_rsync_bwlimit, ENV['BWLIMIT'] # like 20000\nset :bundle_rsync_config_files, ['~/config/database.yml']\n\nset :application, 'sample'\nset :repo_url, \"git@github.com:sonots/rails-sample.git\"\nset :deploy_to, \"/home/sonots/sample\"\nset :rbenv_ruby, \"2.1.2\" # Required on both deploy machine and remote machines\nset :ssh_options, user: 'sonots', keys: [File.expand_path('~/.ssh/id_rsa'), File.expand_path('~/.ssh/id_dsa')]\n\nrole :app, ['127.0.0.1']\n```\n\nDeploy by following command:\n\n```bash\n$ bundle exec cap localhost deploy\n```\n\n## Run a custom task before rsyncing\n\nFor example, if you want to precompile rails assets before rsyncing,\nyou may add your own task before `bundle_rsync:rsync_release`.\n\n```ruby\ntask :precompile do\n  config = Capistrano::BundleRsync::Config\n  run_locally do\n    Bundler.with_clean_env do\n      within config.local_release_path do\n        execute :bundle, 'install' # install development gems\n        execute :bundle, 'exec rake assets:precompile'\n      end\n    end\n    \n    hosts = release_roles(:all)\n    Parallel.each(hosts, in_threads: config.max_parallels(hosts)) do |host|\n      execute \"rsync -az -e ssh #{config.local_release_path}/public/ #{host}:#{fetch(:deploy_to)}/shared/public\"\n    end\n  end\nend\n\nbefore \"bundle_rsync:rsync_release\", \"precompile\"\n```\n\n## local_git scm\n\n`bundle_rsync` supports `local_git` SCM strategy in addition to `git`.\n\n`local_git` strategy enables to rsync the git repository located on a local path without git clone. You may find as this is useful when you need to replace files locally without commit beforehand (for example, for password embedding). \n\nFollowing is an example of `config/deploy/xxxx.rb`:\n\nPlease note that `repo_url` should be a different path with the path running cap. \nThis strategy probably fits with a rare situation, you should use the default `git` strategy usually. \n\n```ruby\nset :branch, ENV['BRANCH'] || 'master'\nset :rbenv_type, :user\nset :linked_dirs, %w(log tmp/pids tmp/cache tmp/sockets vendor/bundle tmp/run)\nset :keep_releases, 5\nset :scm, :bundle_rsync\nset :bundle_rsync_scm, 'local_git' # Set `local_git`\n\nset :application, 'sample'\nset :repo_url, \"/path/to/app/local\" # Need to git clone your repository to this path beforehand.\n                                    # This path should be different with the path running cap.\nset :deploy_to, \"/path/to/app/production\"\nset :rbenv_ruby, \"2.1.2\" # Required the same ruby on both deploy machine and remote machines\nset :ssh_options, user: 'sonots', keys: File.expand_path('~/.ssh/id_rsa')\n\nrole :app, ['127.0.0.1']\n```\n\n## FAQ\n\nQ. What is difference with [capistrano-rsync](https://github.com/moll/capistrano-rsync)?\n\nA. capistrano-bundle\\_rsync does `bundle install` at the deploy machine, not on each remote machine. \n\n## ToDo\n\n1. Support other SCMs than `git`. \n\n## ChangeLog\n\n[CHANGELOG.md](./CHANGELOG.md)\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Copyright\n\nSee [LICENSE.txt](./LICENSE.txt) for details.\n\n## Special Thanks\n\ncapistrano-bundle_rsync was originally created by [@tohae](https://github.com/tohae). Thank you very much!\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonots%2Fcapistrano-bundle_rsync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonots%2Fcapistrano-bundle_rsync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonots%2Fcapistrano-bundle_rsync/lists"}