cf-deploy 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +24 -16
- data/lib/cf/deploy.rb +6 -0
- data/lib/cf/deploy/blue_green.rb +7 -1
- data/lib/cf/deploy/commands.rb +4 -0
- data/lib/cf/deploy/env_config.rb +5 -0
- data/lib/cf/deploy/version.rb +1 -1
- data/spec/blue_green_task_spec.rb +3 -3
- data/spec/deploy_task_spec.rb +15 -0
- data/spec/flip_task_spec.rb +4 -4
- data/spec/stop_idle_task_spec.rb +2 -2
- metadata +21 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c13f96911baa9e48367e8364a4bd5a0cab6bfee2
|
4
|
+
data.tar.gz: 40048b9a6f91b11c8c6eea1083ce708e1c68e988
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 78b67eb6b3e8cffb7a73f443baca3f9170c65d6e49c0cce6fe0f5019605489bf09806a598cd0853a7db94377cc5ba57468311cd42615f263714126726abc0a4c
|
7
|
+
data.tar.gz: 5a68c1ca42162ecd53bf1cbc964589e9888ff575da732b0711792a6c1bed0e3e7212c3d2e3fdd776d26f580cb8be584e6f8de916d482ef5174166c3c97e34a81
|
data/README.md
CHANGED
@@ -1,20 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# CloudFoundry Rails Deployment
|
2
2
|
|
3
|
-
[![Code Climate](https://codeclimate.com/github/
|
4
|
-
[![Build Status](https://travis-ci.org/
|
5
|
-
[![Test Coverage](https://codeclimate.com/github/
|
3
|
+
[![Code Climate](https://codeclimate.com/github/madetech/cf-deploy/badges/gpa.svg)](https://codeclimate.com/github/madetech/cf-deploy)
|
4
|
+
[![Build Status](https://travis-ci.org/madetech/cf-deploy.svg?branch=master)](https://travis-ci.org/madetech/cf-deploy)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/madetech/cf-deploy/badges/coverage.svg)](https://codeclimate.com/github/madetech/cf-deploy/coverage)
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
`cf-deploy` is the tool you use to deploy your rails app to
|
8
|
+
[CloudFoundry][CloudFoundry] providers like [Pivotal][Pivotal]. It works with
|
9
|
+
rails 4.2 and older versions as far back as rails 3.
|
9
10
|
|
10
|
-
|
11
|
+
```
|
12
|
+
rake cf:deploy:production
|
13
|
+
```
|
11
14
|
|
12
|
-
|
13
|
-
environment variables
|
14
|
-
* Implement blue/green deployment
|
15
|
-
* Hook into your existing rake tasks for preparing deploys/syncing assets
|
15
|
+
## `cf-deploy` makes it easy to:
|
16
16
|
|
17
|
-
|
17
|
+
* Deploy your rails app with one rake command
|
18
|
+
* Implement blue/green deployments
|
19
|
+
* Run asset precompiles before deploying your app
|
20
|
+
* Automate your rails deploys using jenkins, circle-ci, codeship
|
21
|
+
|
22
|
+
## Getting Started
|
18
23
|
|
19
24
|
The functionality comes in the shape of generated rake tasks. You require this
|
20
25
|
gem in your `Rakefile` and call the `.rake_tasks!` setup method.
|
@@ -33,10 +38,10 @@ bundle exec rake cf:deploy:staging
|
|
33
38
|
bundle exec rake cf:deploy:production
|
34
39
|
```
|
35
40
|
|
36
|
-
|
37
|
-
`cf push -f manifests/production.yml`.
|
38
|
-
|
39
|
-
|
41
|
+
You now have rake tasks that run `cf push -f manifests/staging.yml` and
|
42
|
+
`cf push -f manifests/production.yml`. Things start to get more exciting
|
43
|
+
when you define your environments in your `Rakefile` along with their task
|
44
|
+
dependencies just like normal rake task syntax.
|
40
45
|
|
41
46
|
``` ruby
|
42
47
|
require 'cf-deploy'
|
@@ -108,6 +113,9 @@ CF::Deploy.rake_tasks! do
|
|
108
113
|
route 'example-app.io', flip: true
|
109
114
|
route 'example-app.io', 'www', flip: true
|
110
115
|
route 'example-app.io', 'www-origin', flip: true
|
116
|
+
|
117
|
+
route 'example-app.io', 'blue', blue: true
|
118
|
+
route 'example-app.io', 'green', green: true
|
111
119
|
end
|
112
120
|
end
|
113
121
|
```
|
data/lib/cf/deploy.rb
CHANGED
data/lib/cf/deploy/blue_green.rb
CHANGED
@@ -53,12 +53,18 @@ module CF
|
|
53
53
|
env[:routes].select { |r| r[:flip] == true }
|
54
54
|
end
|
55
55
|
|
56
|
+
def flip_routes_sorted_by_hostname(env)
|
57
|
+
flip_routes(env).sort do |a, b|
|
58
|
+
a[:hostname] && a[:hostname].length > 0 ? -1 : 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
56
62
|
def match_flip_route_grep(env)
|
57
63
|
if flip_routes(env).empty?
|
58
64
|
raise 'Blue/green deploys require at least one flip_route'
|
59
65
|
end
|
60
66
|
|
61
|
-
|
67
|
+
flip_routes_sorted_by_hostname(env).first.values_at(:hostname, :domain).compact.join(' *')
|
62
68
|
end
|
63
69
|
|
64
70
|
def live_color(env)
|
data/lib/cf/deploy/commands.rb
CHANGED
data/lib/cf/deploy/env_config.rb
CHANGED
@@ -13,6 +13,7 @@ module CF
|
|
13
13
|
task_name: EnvConfig.task_name(name),
|
14
14
|
deps: deps,
|
15
15
|
routes: [],
|
16
|
+
runtime_memory: nil,
|
16
17
|
manifests: manifests)
|
17
18
|
|
18
19
|
instance_eval(&block) if block_given?
|
@@ -74,6 +75,10 @@ module CF
|
|
74
75
|
self[:manifests].concat(manifests)
|
75
76
|
end
|
76
77
|
|
78
|
+
def runtime_memory(memory)
|
79
|
+
self[:runtime_memory] = memory
|
80
|
+
end
|
81
|
+
|
77
82
|
def route(domain, hostname_or_options = nil, options = nil)
|
78
83
|
if options.nil?
|
79
84
|
if hostname_or_options.nil?
|
data/lib/cf/deploy/version.rb
CHANGED
@@ -28,7 +28,7 @@ describe CF::Deploy do
|
|
28
28
|
it 'should deploy blue if not currently deployed' do
|
29
29
|
rake_tasks!
|
30
30
|
expect(Kernel).to receive(:system).with('cf login').ordered
|
31
|
-
expect(IO).to receive(:popen).with(
|
31
|
+
expect(IO).to receive(:popen).with(/cf routes \| grep '(www|www-origin) \*yourwebsite.com'/) { double(read: '', close: nil) }
|
32
32
|
expect(Kernel).to receive(:system).with('cf push -f manifests/production_blue.yml').and_return(true).ordered
|
33
33
|
Rake::Task['cf:deploy:production'].invoke
|
34
34
|
end
|
@@ -36,7 +36,7 @@ describe CF::Deploy do
|
|
36
36
|
it 'should deploy blue if green currently deployed' do
|
37
37
|
rake_tasks!
|
38
38
|
expect(Kernel).to receive(:system).with('cf login').ordered
|
39
|
-
expect(IO).to receive(:popen).with(
|
39
|
+
expect(IO).to receive(:popen).with(/cf routes \| grep '(www|www-origin) \*yourwebsite.com'/) { double(read: 'production-green-app', close: nil) }
|
40
40
|
expect(Kernel).to receive(:system).with('cf push -f manifests/production_blue.yml').and_return(true).ordered
|
41
41
|
Rake::Task['cf:deploy:production'].invoke
|
42
42
|
end
|
@@ -44,7 +44,7 @@ describe CF::Deploy do
|
|
44
44
|
it 'should deploy green if blue currently deployed' do
|
45
45
|
rake_tasks!
|
46
46
|
expect(Kernel).to receive(:system).with('cf login').ordered
|
47
|
-
expect(IO).to receive(:popen).with(
|
47
|
+
expect(IO).to receive(:popen).with(/cf routes \| grep '(www|www-origin) \*yourwebsite.com'/) { double(read: 'production-blue-app', close: nil) }
|
48
48
|
expect(Kernel).to receive(:system).with('cf push -f manifests/production_green.yml').and_return(true).ordered
|
49
49
|
Rake::Task['cf:deploy:production'].invoke
|
50
50
|
end
|
data/spec/deploy_task_spec.rb
CHANGED
@@ -65,6 +65,21 @@ describe CF::Deploy do
|
|
65
65
|
Rake::Task['cf:deploy:test'].invoke
|
66
66
|
end
|
67
67
|
|
68
|
+
it 'should change memory after deployment if runtime_memory specified' do
|
69
|
+
Dir.chdir('spec/') do
|
70
|
+
described_class.rake_tasks! do
|
71
|
+
environment :staging do
|
72
|
+
runtime_memory '256M'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
expect(Kernel).to receive(:system).with('cf login').ordered
|
78
|
+
expect(Kernel).to receive(:system).with('cf push -f manifests/staging.yml').and_return(true).ordered
|
79
|
+
expect(Kernel).to receive(:system).with('cf scale staging-app -m 256M').and_return(true).ordered
|
80
|
+
Rake::Task['cf:deploy:staging'].invoke
|
81
|
+
end
|
82
|
+
|
68
83
|
it 'should not map routes if push command fails' do
|
69
84
|
Dir.chdir('spec/') do
|
70
85
|
described_class.rake_tasks! do
|
data/spec/flip_task_spec.rb
CHANGED
@@ -23,11 +23,11 @@ describe CF::Deploy do
|
|
23
23
|
rake_tasks!
|
24
24
|
expect(Kernel).to receive(:system).with('cf login').ordered
|
25
25
|
|
26
|
-
expect(IO).to receive(:popen).with(
|
26
|
+
expect(IO).to receive(:popen).with(/cf routes \| grep '(www|www-origin) \*yourwebsite.com'/) { double(read: 'production-green-app', close: nil) }
|
27
27
|
expect(Kernel).to receive(:system).with('cf map-route production-blue-app yourwebsite.com').ordered
|
28
28
|
expect(Kernel).to receive(:system).with('cf unmap-route production-green-app yourwebsite.com').ordered
|
29
29
|
|
30
|
-
expect(IO).to receive(:popen).with(
|
30
|
+
expect(IO).to receive(:popen).with(/cf routes \| grep '(www|www-origin) \*yourwebsite.com'/) { double(read: 'production-green-app', close: nil) }
|
31
31
|
expect(Kernel).to receive(:system).with('cf map-route production-blue-app yourwebsite.com -n www').ordered
|
32
32
|
expect(Kernel).to receive(:system).with('cf unmap-route production-green-app yourwebsite.com -n www').ordered
|
33
33
|
|
@@ -43,11 +43,11 @@ describe CF::Deploy do
|
|
43
43
|
rake_tasks!
|
44
44
|
expect(Kernel).to receive(:system).with('cf login').ordered
|
45
45
|
|
46
|
-
expect(IO).to receive(:popen).with(
|
46
|
+
expect(IO).to receive(:popen).with(/cf routes \| grep '(www|www-origin) \*yourwebsite.com'/) { double(read: 'production-blue-app', close: nil) }
|
47
47
|
expect(Kernel).to receive(:system).with('cf map-route production-green-app yourwebsite.com').ordered
|
48
48
|
expect(Kernel).to receive(:system).with('cf unmap-route production-blue-app yourwebsite.com').ordered
|
49
49
|
|
50
|
-
expect(IO).to receive(:popen).with(
|
50
|
+
expect(IO).to receive(:popen).with(/cf routes \| grep '(www|www-origin) \*yourwebsite.com'/) { double(read: 'production-blue-app', close: nil) }
|
51
51
|
expect(Kernel).to receive(:system).with('cf map-route production-green-app yourwebsite.com -n www').ordered
|
52
52
|
expect(Kernel).to receive(:system).with('cf unmap-route production-blue-app yourwebsite.com -n www').ordered
|
53
53
|
|
data/spec/stop_idle_task_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe CF::Deploy do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
it 'should stop
|
19
|
+
it 'should stop blue if green is currently mapped' do
|
20
20
|
Dir.chdir('spec/') do
|
21
21
|
rake_tasks!
|
22
22
|
expect(Kernel).to receive(:system).with('cf login').ordered
|
@@ -26,7 +26,7 @@ describe CF::Deploy do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
it 'should stop
|
29
|
+
it 'should stop green if blue is currently mapped' do
|
30
30
|
Dir.chdir('spec/') do
|
31
31
|
rake_tasks!
|
32
32
|
expect(Kernel).to receive(:system).with('cf login').ordered
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cf-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Luke Morton
|
@@ -10,86 +9,76 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2015-
|
12
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rake
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '0'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: bundler
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- - ~>
|
32
|
+
- - "~>"
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '1.5'
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- - ~>
|
39
|
+
- - "~>"
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '1.5'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: rspec
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- - ~>
|
46
|
+
- - "~>"
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: 3.0.0
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- - ~>
|
53
|
+
- - "~>"
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: 3.0.0
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: simplecov
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
|
-
- - ~>
|
60
|
+
- - "~>"
|
69
61
|
- !ruby/object:Gem::Version
|
70
62
|
version: 0.7.1
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
|
-
- - ~>
|
67
|
+
- - "~>"
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: 0.7.1
|
79
70
|
- !ruby/object:Gem::Dependency
|
80
71
|
name: codeclimate-test-reporter
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
73
|
requirements:
|
84
|
-
- -
|
74
|
+
- - ">="
|
85
75
|
- !ruby/object:Gem::Version
|
86
76
|
version: '0'
|
87
77
|
type: :development
|
88
78
|
prerelease: false
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
80
|
requirements:
|
92
|
-
- -
|
81
|
+
- - ">="
|
93
82
|
- !ruby/object:Gem::Version
|
94
83
|
version: '0'
|
95
84
|
description:
|
@@ -100,13 +89,15 @@ executables: []
|
|
100
89
|
extensions: []
|
101
90
|
extra_rdoc_files: []
|
102
91
|
files:
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- lib/cf-deploy.rb
|
95
|
+
- lib/cf/deploy.rb
|
103
96
|
- lib/cf/deploy/blue_green.rb
|
104
97
|
- lib/cf/deploy/commands.rb
|
105
98
|
- lib/cf/deploy/config.rb
|
106
99
|
- lib/cf/deploy/env_config.rb
|
107
100
|
- lib/cf/deploy/version.rb
|
108
|
-
- lib/cf/deploy.rb
|
109
|
-
- lib/cf-deploy.rb
|
110
101
|
- spec/blue_green_task_spec.rb
|
111
102
|
- spec/deploy_task_spec.rb
|
112
103
|
- spec/flip_task_spec.rb
|
@@ -114,31 +105,28 @@ files:
|
|
114
105
|
- spec/rake_tasks_spec.rb
|
115
106
|
- spec/spec_helper.rb
|
116
107
|
- spec/stop_idle_task_spec.rb
|
117
|
-
- LICENSE
|
118
|
-
- README.md
|
119
108
|
homepage: https://github.com/madebymade/cf-deploy
|
120
109
|
licenses:
|
121
110
|
- MIT
|
111
|
+
metadata: {}
|
122
112
|
post_install_message:
|
123
113
|
rdoc_options: []
|
124
114
|
require_paths:
|
125
115
|
- lib
|
126
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
117
|
requirements:
|
129
|
-
- -
|
118
|
+
- - ">="
|
130
119
|
- !ruby/object:Gem::Version
|
131
120
|
version: '0'
|
132
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
122
|
requirements:
|
135
|
-
- -
|
123
|
+
- - ">="
|
136
124
|
- !ruby/object:Gem::Version
|
137
125
|
version: '0'
|
138
126
|
requirements: []
|
139
127
|
rubyforge_project:
|
140
|
-
rubygems_version:
|
128
|
+
rubygems_version: 2.4.5
|
141
129
|
signing_key:
|
142
|
-
specification_version:
|
130
|
+
specification_version: 4
|
143
131
|
summary: Rake tasks for deploying to CloudFoundry v6+
|
144
132
|
test_files: []
|