capistrano-docker-compose 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 417530036951e12bdae99b9831027203d072d12b
4
- data.tar.gz: cdaac309914c1549e288c9fec881eb3dfbdfb6de
3
+ metadata.gz: 3a78b926b2d20c381ed686e1ca9597e4578a3f4f
4
+ data.tar.gz: c42472026088ce99c022ae0b2771fb8331944ee3
5
5
  SHA512:
6
- metadata.gz: 3430986a6503bf22c18f7f2a993075c782edd5d57368433b7ef49e7b606c7a958a773b0054fb6958321b2b7a6613bd5cf485151dcda0a5bacabd2b57b969c3ed
7
- data.tar.gz: 600eb2f61fce082ba51569d7a8423fc086d7171b74921a8f01fd4f864fd203e8dd828bbad157911414742f16a55a6f3239656ac320ef8c2e01f23ab44fff175d
6
+ metadata.gz: 0f2ffacd8175a840f923c1b870fa7e30fcc7dc24ec393b2d16d0955ffb551a455fbd73f3f76b9c50cb3843ee73baa16145e733f54a80f7c198a74a0480ee0229
7
+ data.tar.gz: bbf5d000ad735710e747c716fb612bec5945013883e50e32881f688498bff6d07a32423825ac310deb2a73d4378e5358f96f5356ca910b3b4acb6bac89ca6a32
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.3.1
4
+ - 2.3.3
5
+ - 2.4.0
5
6
 
6
7
  install:
7
8
  - bundle
data/README.md CHANGED
@@ -2,13 +2,20 @@
2
2
 
3
3
  Docker Compose specific tasks for Capistrano allowing seamless zero downtime containerised deployments.
4
4
 
5
- ## Requirements
5
+ ## Minimum requirements
6
6
 
7
7
  - Capistrano 3.5
8
8
  - Docker Engine 1.11
9
9
  - Docker Compose 1.7
10
10
  - HAProxy 1.6
11
11
 
12
+ ## Supported databases
13
+
14
+ | Database | Versions tested |
15
+ | -------- | --------------- |
16
+ | PostgreSQL  | 9.5 |
17
+ | MariaDB | 5.5 |
18
+
12
19
  ## Installation
13
20
 
14
21
  Add this line to your application's Gemfile:
@@ -27,50 +34,76 @@ Or install it yourself as:
27
34
 
28
35
  ## Usage
29
36
 
30
- Create Docker Compose descriptors for each environment leaving `docker-compose.yml` as default for development environment, e.g.:
37
+ 1. Create Docker Compose descriptors for each environment leaving `docker-compose.yml` as default for development environment, e.g.:
31
38
 
32
39
  - `docker-compose.yml`
33
40
  - `docker-compose-staging.yml`
34
41
  - `docker-compose-production.yml`
35
42
 
36
- Make Compose YAML with `web` service using following environment variables:
43
+ 2. Make Compose YAML with `web` service (name is conventional) using following environment variables:
37
44
 
38
- - `CAP_DOCKER_COMPOSE_ROOT_PATH` for shared path
39
- - `CAP_DOCKER_COMPOSE_PORT` for port range
45
+ - `CAP_DOCKER_COMPOSE_ROOT_PATH` for shared path
46
+ - `CAP_DOCKER_COMPOSE_PORT` for port range
40
47
 
41
- See also [Compose YAML example](https://github.com/interactive-pioneers/capistrano-docker-compose/blob/master/docker-compose-staging.example.yml).
48
+ 3. If you're using database service with migrations in Ruby on Rails, make sure to name database service as `db` (name is conventional). See also [Compose YAML example](https://github.com/interactive-pioneers/capistrano-docker-compose/blob/master/docker-compose-staging.example.yml).
42
49
 
43
- Add `capistrano-docker-compose` to `Capfile`:
50
+ 4. Add `capistrano-docker-compose` to `Capfile`:
44
51
 
45
- ``` ruby
46
- # Capfile
47
- require 'capistrano/docker/compose'
48
- ```
52
+ ``` ruby
53
+ # Capfile
54
+ require 'capistrano/docker/compose'
55
+ ```
49
56
 
50
- Configure following Docker Compose specific options in `config/deploy.rb` and/or `config/deploy/<environment>.rb`:
57
+ 5. Configure following Docker Compose specific options in `config/deploy.rb` and/or `config/deploy/<environment>.rb`:
51
58
 
52
- ```ruby
53
- # Define port range in respect to load balancer on server
54
- # If 2 or more environments reside on same server, configure port range as per environment
55
- # Ruby's Range object is expected, see http://ruby-doc.org/core-2.3.0/Range.html
56
- # Example: set :docker_compose_port_range, 2070..2071
57
- set :docker_compose_port_range, <port>..<port>
58
-
59
- # OPTIONAL
60
- # User name when running the Docker image (reflecting Docker's USER instruction)
61
- # Example: set :docker_compose_user, 'pioneer'
62
- set :docker_compose_user, '<username>'
63
-
64
- # OPTIONAL
65
- # Roles considered
66
- # Defaults to :all
67
- # Example: set :docker_compose_roles, :web
68
- set :docker_compose_roles, <roles>
69
- ```
59
+ ```ruby
60
+ # Define port range in respect to load balancer on server
61
+ # If 2 or more environments reside on same server, configure port range as per environment
62
+ # Ruby's Range object is expected, see http://ruby-doc.org/core-2.3.0/Range.html
63
+ # Example: set :docker_compose_port_range, 2070..2071
64
+ set :docker_compose_port_range, <port>..<port>
65
+
66
+ # OPTIONAL
67
+ # User name when running the Docker image (reflecting Docker's USER instruction)
68
+ # Example: set :docker_compose_user, 'pioneer'
69
+ set :docker_compose_user, '<username>'
70
+
71
+ # OPTIONAL
72
+ # Roles considered
73
+ # Defaults to :all
74
+ # Example: set :docker_compose_roles, :web
75
+ set :docker_compose_roles, <roles>
76
+ ```
77
+
78
+ 6. Configure HAProxy load balancer with port range defined in `docker_compose_port_range`, see [example configuration](https://github.com/interactive-pioneers/capistrano-docker-compose/blob/master/haproxy.example.cfg).
70
79
 
71
- Configure load balancer with port range defined in `docker_compose_port_range`, see [example configuration](https://github.com/interactive-pioneers/capistrano-docker-compose/blob/master/haproxy.example.cfg).
80
+ NB! Ensure load balancer's HTTP health check uses Layer 7 and corresponds to the needs of the particular application.
72
81
 
73
- NB! Ensure load balancer's HTTP health check uses Layer 7 and corresponds to the needs of the particular application.
82
+ ### PHP projects
83
+
84
+ To use `capistrano-docker-compose` on PHP project, such as Wordpress or Drupal:
85
+
86
+ 1. Add `Gemfile` to project root:
87
+
88
+ ```ruby
89
+ # Gemfile
90
+ source 'https://rubygems.org'
91
+
92
+ group :capistrano do
93
+ gem 'capistrano-bundler'
94
+ gem 'capistrano-docker-compose'
95
+ end
96
+ ```
97
+ 2. Run `bundle` to install
98
+
99
+ If bundling is not desired during deployment (no RubyGems dependencies), Capistrano flow can be altered by removing bundler task:
100
+
101
+ ```ruby
102
+ # config/deploy.rb
103
+ namespace :deploy do
104
+ Rake::Task["bundler:install"].clear_actions
105
+ end
106
+ ```
74
107
 
75
108
  ## Contributing
76
109
 
@@ -78,4 +111,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/intera
78
111
 
79
112
  ## Licence
80
113
 
81
- Copyright © 2016 Ain Tohvri, Interactive Pioneers GmbH. Licenced under [GPL-3](https://github.com/interactive-pioneers/capistrano-docker-compose/blob/master/LICENSE).
114
+ Copyright © 2016, 2017 Ain Tohvri, Interactive Pioneers GmbH. Licenced under [GPL-3](https://github.com/interactive-pioneers/capistrano-docker-compose/blob/master/LICENSE).
@@ -20,8 +20,4 @@ Gem::Specification.new do |spec|
20
20
  spec.required_ruby_version = "~> 2.0"
21
21
 
22
22
  spec.add_dependency 'capistrano', '~> 3.5'
23
-
24
- spec.add_development_dependency 'bundler', '~> 1.11'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 3.0'
27
23
  end
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  module Docker
3
3
  module Compose
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9"
5
5
  end
6
6
  end
7
7
  end
@@ -25,7 +25,7 @@ namespace :deploy do
25
25
  with cap_docker_compose_root_path: fetch(:deploy_to), cap_docker_compose_port: detect_available_port do
26
26
  execute :'docker-compose', '-f', "docker-compose-#{fetch(:rails_env)}.yml", 'up', '-d'
27
27
  # Give services 3s to come up
28
- # TODO: implement flexibly into options
28
+ # TODO: implement flexibly into options as timeout
29
29
  sleep 3
30
30
  end
31
31
  end
@@ -46,24 +46,13 @@ namespace :deploy do
46
46
  task :purge_old_containers do
47
47
  on roles(fetch(:docker_compose_roles)) do
48
48
  if fetch(:previous_release_path, false)
49
- info "Purging previous release containers at #{fetch(:previous_release_path)}"
50
-
51
- release_name = Pathname.new(release_path).basename.to_s
52
- web_container_id = capture("docker ps -q --filter 'name=#{release_name}_web'")
53
- execute :docker, 'pause', web_container_id
54
-
55
49
  within fetch(:previous_release_path) do
56
- execute :'docker-compose', 'down'
50
+ containers = capture :'docker-compose', 'ps', '-q'
51
+ unless containers.empty?
52
+ info "Purging containers of previous release at #{fetch(:previous_release_path)}"
53
+ execute :'docker-compose', 'down'
54
+ end
57
55
  end
58
-
59
- db_container_id = capture("docker ps -q --filter 'name=#{release_name}_db'")
60
- execute :docker, 'restart', db_container_id
61
-
62
- # Give services 3s to come up
63
- # TODO: implement flexibly into options
64
- sleep 3
65
-
66
- execute :docker, 'unpause', web_container_id
67
56
  end
68
57
  end
69
58
  end
@@ -72,8 +61,30 @@ namespace :deploy do
72
61
  set :cap_docker_compose_failed, true
73
62
  on roles(fetch(:docker_compose_roles)) do
74
63
  within release_path do
64
+ info "Purging failed containers at #{release_path}"
75
65
  execute :'docker-compose', 'down'
76
66
  end
67
+ within fetch(:previous_release_path) do
68
+ containers = capture :'docker-compose', 'ps', '-q'
69
+ unless containers.empty?
70
+ info "Restarting containers of previous release"
71
+ execute :'docker-compose', 'start'
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ task :stop_previous_release do
78
+ on roles(fetch(:docker_compose_roles)) do
79
+ if fetch(:previous_release_path, false)
80
+ within fetch(:previous_release_path) do
81
+ containers = capture :'docker-compose', 'ps', '-q'
82
+ unless containers.empty?
83
+ info "Stopping containers of previous release"
84
+ execute :'docker-compose', 'stop'
85
+ end
86
+ end
87
+ end
77
88
  end
78
89
  end
79
90
 
@@ -100,6 +111,7 @@ namespace :deploy do
100
111
 
101
112
  after :updating, :pull_images
102
113
  after :updating, :start_containers
114
+ before :migrate, :stop_previous_release
103
115
  before :publishing, :claim_files_by_container
104
116
  before :failed, :claim_files_by_container
105
117
  after :failed, :purge_failed_containers
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-docker-compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ain Tohvri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2017-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -24,48 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.5'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.11'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.11'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
69
27
  description: Docker Compose specific tasks for Capistrano allowing seamless zero downtime
70
28
  containerised deployments.
71
29
  email: