Build and deploy docker images with capistrano.
Add this line to your application’s Gemfile:
gem 'capistrano-docker',
git: "https://github.com/goldstarlearning/capistrano-docker.git"And then execute:
bundleAdd this line to your capistrano configuration:
require "capistrano/docker"capistrano-docker uses these variables to name docker images and containers:
set :organization, "orgname"
set :application, "myapp"
set :branch, fetch(ENV["BRANCH"], `git rev-parse --abbrev-ref HEAD`.rstrip)Docker images will be named/tagged as: `organization/application:branch-SHA`
Currently, the docker image is built on the primary server having the `build’ role, then copied and installed on all servers with the `app’ role. Implying a stage set-up that includes something like the following:
server ENV["APP_SERVER"],
user: "deploy",
roles: %w{app web}
server ENV["BUILD_SERVER"],
user: "deploy",
roles: %w{build},
primary: truecd test-app && bundle exec cap -T docker| cap docker:build | Build the docker image |
| cap docker:clean | Clean docker image files older than :keep_images_for_days [default: 3] |
| cap docker:deploy | Run the application container |
| cap docker:install | Install built docker image onto application servers |
| cap docker:ps | Show running docker containers |
| cap docker:pull | Pull the latest docker build |
| cap docker:show | List running container for deployment branch |
Bug reports and pull requests are welcome on GitHub at https://github.com/goldstarlearning/capistrano-docker.
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).