⚠️ When testing this, do not run bundle exec cap production deploy as the branch is still set to master, and not to this one. If you want to test it first before approving, change set :branch, 'master' to set :branch, 'capistrano-docker'.
When you want to deploy, just run bundle exec cap production deploy locally, it will do everything:
Create a new version on the server
Build docker containers
Stop the old dockers
Boot the new ones
Execute migrations if necessary
Update whenever and the crontab
Useful commands:
bundle exec capistrano deploy: Deploys the application
bundle exec capistrano docker:compose:logs:tail: Gets a tail of the logs
bundle exec capistrano docker:compose:logs:follow: Follows the logs
bundle exec cap production docker:compose:db:migrate: Migrates
I'm still playing around with these and with the name, for a full list, execute bundle exec cap --tasks.
For the docker:compose:* tasks, the service defaults to web. In short, it's trying to find to find a container with :docker_compose_project_name.*:service as regex. :docker_compose_project_name is set in the deploy.rb file, the service can be overwritten using default Rake syntax: bundle exec cap production 'docker:compose:logs:tail[db]'. I'm sorry for the syntax, but it is what it is.
Updates #582
⚠️ When testing this, do not run
bundle exec cap production deploy
as thebranch
is still set tomaster
, and not to this one. If you want to test it first before approving, changeset :branch, 'master'
toset :branch, 'capistrano-docker'
.Draft PR for docker support, uses https://github.com/TomNaessens/capistrano-docker as capistrano goodies.
When you want to deploy, just run
bundle exec cap production deploy
locally, it will do everything:whenever
and the crontabUseful commands:
bundle exec capistrano deploy
: Deploys the applicationbundle exec capistrano docker:compose:logs:tail
: Gets a tail of the logsbundle exec capistrano docker:compose:logs:follow
: Follows the logsbundle exec cap production docker:compose:db:migrate
: MigratesI'm still playing around with these and with the name, for a full list, execute
bundle exec cap --tasks
.For the
docker:compose:*
tasks, theservice
defaults toweb
. In short, it's trying to find to find a container with:docker_compose_project_name.*:service
as regex.:docker_compose_project_name
is set in the deploy.rb file, theservice
can be overwritten using default Rake syntax:bundle exec cap production 'docker:compose:logs:tail[db]'
. I'm sorry for the syntax, but it is what it is.