capose 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +78 -1
  3. data/capose.gemspec +1 -1
  4. data/lib/capose.rb +5 -2
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2591e5750c3c48278502ea9f067f0bc3c0d491f
4
- data.tar.gz: 06dd8ff0fa00a720e23a2a02e19abf0fa1a0f82a
3
+ metadata.gz: 7e6f8a2c0c980db34d6fb2dd55dfafacd6dabc6a
4
+ data.tar.gz: b9184a027af5647837f95370d973391193790ec9
5
5
  SHA512:
6
- metadata.gz: 482e6c5bf895277fff76a1bb1185820d34323ff91bff806fe0d73f684c3017a418f7c3393c988e9bf55a41f4b5ea8f217aa2af64e84a9e9d3b7653e85ee9ef0c
7
- data.tar.gz: fe2d2ece25816175ecca3371499aaf50c44a0b9d61e8c6b7c575f872aa6d4ae71645347e854d500f6b52aaa4d720abd2964216d19d8a15ec7184623fdd6d877c
6
+ metadata.gz: e6a9a70d75447f419c3531f9c9ea4177f815090847d4b52b2affa1461aa5209f71dfd15ba216e1f1a0d12dcb88933a32bad3fbef3b5ee06107a31f170863c0b6
7
+ data.tar.gz: e60ffc83cf97d570775ca9158d21ef34033f92c107f9e2ac17fd2434372d1b24d8049d6d7e9372e237a8d4f4f99f77db1d519fe38c1d65631c304bf48c6e4ec7
data/README.md CHANGED
@@ -1,4 +1,81 @@
1
1
  # Capose - A capistrano addon to use with docker-compose
2
2
 
3
- This gem is a lighter version of https://github.com/netguru/capistrano-docker that aims to work only with docker-compose. The idea is to have a minimal possible capistrano configuration and use the power of docker-compose to build images and run containers.
3
+ This gem is a lighter version of docker-compose strategy found in [capistrano-docker](https://github.com/netguru/capistrano-docker) gem. The idea is to be much simplier and more custom to use.
4
4
 
5
+ The idea behind this gem came when working with docker-compose deployments. I realized that most of the time the commands I am using are "build" and "up -d". Along with giving the name of the project and the docker-compose file path, the defaults in this gem should be enough for you just to require the gem and deploy should work.
6
+
7
+ ### Installation
8
+
9
+ 1. Ensure you already have `capistrano` gem in your project, with version at least `3.7`
10
+ 2. Add the following line to your `Gemfile`: `gem 'capose', require: false`
11
+ 3. Add the following file to `Capfile`: `require 'capose'`
12
+
13
+ This gem will automatically hook up to the capistrano after `deploy:updated` hook to perform the deployment via `capose:deploy` hook
14
+
15
+ ### Changelog
16
+ * [0.2.0] - Add `capose_env` - a key/par value of additional environment variables to be exported for compose commands
17
+
18
+ ### Defaults
19
+
20
+ This gem uses couple variables which can be modified inside your deploy scripts, these are:
21
+
22
+ set :capose_role - capistrano role for capose, defaults to :web
23
+ set :capose_copy - list of files/dirs to be copied from shared_path before first command (replaces :link_dirs/files), defaults to []
24
+ set :capose_project - docker-compose project name, defaults to fetch(:application)
25
+ set :capose_file - list of files for the docker-compose -f parameter (defauls to ["docker-compose-#{fetch(:stage)}.yml"])
26
+ set :capose_commands - list of commands to be run with docker-compose, defaults to ['build', 'up -d']
27
+
28
+ With above defaults, if you have: docker-compose-STAGE.yml file and the only thing you want to do is "build" and "up" your app, then the only thing you have to do is to require the capose gem in Capfile.
29
+
30
+ Capistrano will run following commands with default values:
31
+
32
+ docker-compose -p [application] -f docker-compose-[stage].yml build
33
+ docker-compose -p [application] -f docker-compose-[stage].yml up -d
34
+
35
+
36
+ ### Additional hooks to use
37
+ This gem provides total three hooks, the default one, `capose:deploy` automatically is executed upon deployment, the remaning two are
38
+
39
+ 1. `capose:stop`
40
+ 2. `capose:command`
41
+
42
+ `capose:stop` simply runs the command `docker-compose ... stop` in the `current_path`, so you can manually stop the containers.
43
+
44
+ `capose:command` runs the custom command in `current_path` given in `CAPOSE_COMMAND` environment variable, so the usage is: `CAPOSE_COMMAND="some command" cap [stage] capose:command` - this will run a following command: `docker-compose -p [application] -f [compose-file] some command` - you can use capose command to for example restart your containers
45
+
46
+
47
+
48
+ ### Additional files before first command
49
+ If you need to throw in to the "release" folder couple files (say secret files) before image is build, you can use `capose_copy` for that, ex:
50
+
51
+ set :capose_copy, %w(config/secrets.yml certs/google.crt certs/google.key)
52
+
53
+ This command will copy the files from shared/ path before first command is executed, such as:
54
+
55
+ cp -aR [shared_path]/config/secrets.yml [release_path]/config/secrets.yml
56
+ cp -aR [shared_path]/config/google.crt [release_path]/config/google.crt
57
+ cp -aR [shared_path]/config/google.key [release_path]/config/google.key
58
+ docker-compose -p [application] -f ... build
59
+ docker-compose ...
60
+
61
+ ### Additional commands to run
62
+ If your use-case contains more commands than `build` and `up -d`, then you can modify `capose_commands` to achieve that, ex:
63
+
64
+ set :capose_commands, ["build", "run --rm web rake db:migrate", "run --rm web rake assets:precompile", "up -d"]
65
+
66
+ This will tell capistrano to run following commands:
67
+
68
+ docker-compose -p [application] -f docker-compose-[stage].yml build
69
+ docker-compose -p [application] -f docker-compose-[stage].yml run --rm web rake db:migrate
70
+ docker-compose -p [application] -f docker-compose-[stage].yml run --rm web rake assets:precompile
71
+ docker-compose -p [application] -f docker-compose-[stage].yml up -d
72
+
73
+ ### Custom docker-compose file paths
74
+
75
+ If you want to add more compose files or change the name, then modify `capose_file` variable, ex:
76
+
77
+ set :capose_file, ["docker-compose.yml", "docker-compose-override.yml"]
78
+
79
+ This will tell capistrano to run commands as:
80
+
81
+ docker-compose -p [application] -f docker-compose.yml -f docker-compose-override.yml [command]
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'capose'
6
- spec.version = '0.1.0'
6
+ spec.version = '0.2.0'
7
7
  spec.authors = ["Jacek Jakubik"]
8
8
  spec.email = ["jacek.jakubik@netguru.pl"]
9
9
  spec.description = %q{Docker-Compose support for Capistrano 3.x}
@@ -53,8 +53,10 @@ namespace :capose do
53
53
 
54
54
  on roles(fetch(:capose_role)) do
55
55
  within release_path do
56
- fetch(:capose_commands).each do |command|
57
- execute :"docker-compose", _command(command)
56
+ with fetch(:capose_env) do
57
+ fetch(:capose_commands).each do |command|
58
+ execute :"docker-compose", _command(command)
59
+ end
58
60
  end
59
61
  end
60
62
  end
@@ -67,6 +69,7 @@ namespace :load do
67
69
  set :capose_copy, -> { [] }
68
70
  set :capose_project, -> { fetch(:application) }
69
71
  set :capose_file, -> { ["docker-compose-#{fetch(:stage)}.yml"] }
72
+ set :capose_env, -> { {} }
70
73
 
71
74
  set :capose_commands, -> { ["build", "up -d"] }
72
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacek Jakubik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano