Rat is a deploy tool for docker users. It implements a facade around 2 docker CLIs:
- docker
- docker-compose
It is not very flexible and it is untested lightly tested.
I wrote this to avoid running a bunch of time consuming commands in a row.
I named it rat because it is a rather little and ugly ball of code, but it does the job for now.
Rat deployer adds a thin layer of abstraction over docker-compose to make commands more DRY. Main features it adds are:
- Enviromental overrides by using multiple compose files
- Easier remote usage by linking environments to machines
- Slack notifier
$ gem install rat_deployer
Rat searches for a file called rat_config.yml
in the working dir. The options are:
- project_name: together with the environment, is part of the prefix passed to the
--project
option fordocker-compose
- environments: holds environemntal config
- [env]: parametric environment name
- machine: configuration for remote usage. Links environment to a remote host. All paths can be relative to
rat_config.yml
file- host: IP for the remote machine
- ca_cert: path to CA certificate
- cert: path to SSL certificate used
- key: path to SSL certificate key
- machine: configuration for remote usage. Links environment to a remote host. All paths can be relative to
- [env]: parametric environment name
Example config file:
project_name: myapp
environments:
staging:
machine:
host: tcp://107.170.36.78:2376
ca_cert: certs/ca.pem
cert: certs/cert.pem
key: certs/key.pem
Rat most used options are set via environent variables to avoid having to type them all the time.
- RAT_ENV: current enviroment.
- RAT_REMOTE: whether or not to execute commands on remote host. Acceptable values are
true
andfalse
. Defaults totrue
.
I recommend to export them if you are going to work on a environment for a long time:
$ export RAT_ENV=production RAT_REMOTE=false
rat compose cmd
: proxies command to docker-compose adding flags-f config/default.yml -f config/<env>.yml -p <prefix>
. IfRAT_REMOTE
istrue
adds flags for running on remote host.rat deploy [services]
: just an alias forrat compose pull [services] && rat compose up -d [services]
.rat docker cmd
: proxies command to docker-compose adding flags for remote host ffRAT_REMOTE
istrue
.
Example usage:
$ export RAT_ENV=staging
$ rat compose up -d
||=> Running command `docker-compose -f config/default.yml -f config/staging.yml -p cognituz_staging up -d`
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rat_deployer.
The gem is available as open source under the terms of the MIT License.