gantree 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -2
- data/lib/gantree/cli.rb +6 -5
- data/lib/gantree/deploy.rb +10 -6
- data/lib/gantree/docker.rb +8 -9
- data/lib/gantree/stack.rb +1 -1
- data/lib/gantree/version.rb +1 -1
- data/spec/lib/gantree/deploy_spec.rb +24 -0
- data/spec/lib/gantree/docker_spec.rb +19 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 375f0ba44dd429bb2dac4ec8d9d7487cb799f22b
|
4
|
+
data.tar.gz: b71597843a51ddaf68838f4b339e9d6359bb5cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cd977a7179d2b9b09df0313809284e95567f1633e8cdaf4c4143cdf6a4691ef18a3b07817b5afa30054c2fd2cfe821997deacd4ec44144e7f6b984c0ff44556
|
7
|
+
data.tar.gz: 6be3ab8f036c1bdaf56421482f5aa8fc6c0d2a95907092d9eb6c8c91cfd7c409e47e6ee13cd2e82436baa60ffa66f55a2de7c2f5ff1c7fa302cfe4cc5179d93a
|
data/.travis.yml
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- 2.1.
|
5
|
-
before_script:
|
4
|
+
- 2.1.3
|
5
|
+
before_script:
|
6
|
+
- echo "{"https://index.docker.io/v1/":{"auth":"$DOCKER_TOKEN","email":"$DOCKER_EMAIL"}"
|
6
7
|
> $HOME/.dockercfg
|
7
8
|
env:
|
8
9
|
global:
|
9
10
|
- secure: OoLMnBOcoXTPOimdyh4ju8yW2YpLBXEOdljN1gVQzjIIv24cQ0BxWAAktjExntkYAjnRpxzTKK5ZkWadXm8NK7TtzFU80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uLQ7aj5wzWToHdOPkzBIyE5H8DfV84lvsBYktFac5TLoiU+nxl/aSzO11tfIY0gneKEyjSjWIS0zgNXE7F7zTC6R46dPGpq8nnW7dEyZwDKmy8jw=
|
data/lib/gantree/cli.rb
CHANGED
@@ -12,6 +12,7 @@ module Gantree
|
|
12
12
|
method_option :ext, :aliases => "-x", :desc => "ebextensions folder/repo"
|
13
13
|
option :dry_run, :aliases => "-d", :desc => "do not actually deploy the app"
|
14
14
|
option :silent, :aliases => "-s", :desc => "mute notifications"
|
15
|
+
option :image_path, :aliases => "-i", :desc => "docker hub image path ex. (bleacher/cms | quay.io/bleacherreport/cms)"
|
15
16
|
option :autodetect_app_role, :desc => "use naming convention to determin role"
|
16
17
|
def deploy name
|
17
18
|
Gantree::Deploy.new(name, merge_defaults(options)).run
|
@@ -59,14 +60,14 @@ module Gantree
|
|
59
60
|
end
|
60
61
|
|
61
62
|
desc "build", "build and tag a docker application"
|
63
|
+
option :image_path, :aliases => "-i", :desc => "docker hub image path ex. (bleacher/cms | quay.io/bleacherreport/cms)"
|
62
64
|
option :tag, :aliases => "-t", :desc => "set docker tag to build"
|
63
|
-
option :hub, :aliases => "-h", :desc => "hub (docker|quay)"
|
64
65
|
def build
|
65
66
|
Gantree::Docker.new(merge_defaults(options)).build
|
66
67
|
end
|
67
68
|
|
68
69
|
desc "push", "build and tag a docker application"
|
69
|
-
option :
|
70
|
+
option :image_path, :aliases => "-i", :desc => "docker hub image path ex. (bleacher/cms | quay.io/bleacherreport/cms)"
|
70
71
|
option :tag, :aliases => "-t", :desc => "set docker tag to push"
|
71
72
|
def push
|
72
73
|
Gantree::Docker.new(merge_defaults(options)).push
|
@@ -77,16 +78,16 @@ module Gantree
|
|
77
78
|
puts Gantree::Docker.new(merge_defaults(options)).tag
|
78
79
|
end
|
79
80
|
|
80
|
-
desc "
|
81
|
+
desc "ship", "tag a docker application"
|
81
82
|
option :branch, :desc => 'branch to deploy'
|
82
83
|
option :tag, :aliases => "-t", :desc => "set docker tag to deploy", :default => Gantree::Base.new.tag
|
83
84
|
option :ext, :aliases => "-x", :desc => "ebextensions folder/repo"
|
84
85
|
option :dry_run, :aliases => "-d", :desc => "do not actually deploy the app"
|
85
86
|
option :silent, :aliases => "-s", :desc => "mute notifications"
|
86
87
|
option :autodetect_app_role, :desc => "use naming convention to determin role"
|
87
|
-
option :
|
88
|
+
option :image_path, :aliases => "-i", :desc => "hub image path ex. (bleacher/cms | quay.io/bleacherreport/cms)"
|
88
89
|
option :hush, :desc => "quite puts messages", :default => true
|
89
|
-
def
|
90
|
+
def ship server
|
90
91
|
docker = Gantree::Docker.new(merge_defaults(options))
|
91
92
|
docker.build
|
92
93
|
docker.push
|
data/lib/gantree/deploy.rb
CHANGED
@@ -117,7 +117,7 @@ module Gantree
|
|
117
117
|
})
|
118
118
|
puts "Deployed #{@packaged_version} to #{env} on #{@app}".green
|
119
119
|
rescue AWS::ElasticBeanstalk::Errors::InvalidParameterValue
|
120
|
-
puts "Error: Something went wrong
|
120
|
+
puts "Error: Something went wrong during the deploy to #{env}".red
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -131,6 +131,7 @@ module Gantree
|
|
131
131
|
version = "#{@app}-#{hash}-#{time_stamp}"
|
132
132
|
puts "version: #{version}"
|
133
133
|
#auto_detect_app_role if @options[:autodetect_app_role] == true
|
134
|
+
set_image_path if @options[:image_path]
|
134
135
|
set_tag_to_deploy if @options[:tag]
|
135
136
|
unless ext?
|
136
137
|
new_dockerrun = "#{version}-Dockerrun.aws.json"
|
@@ -151,16 +152,19 @@ module Gantree
|
|
151
152
|
IO.write(@dockerrun_file, JSON.pretty_generate(docker))
|
152
153
|
end
|
153
154
|
|
155
|
+
def set_image_path
|
156
|
+
docker = JSON.parse(IO.read(@dockerrun_file))
|
157
|
+
image = docker["Image"]["Name"]
|
158
|
+
image.gsub!(/(.*):/, "#{@options[:image_path]}:")
|
159
|
+
IO.write(@dockerrun_file, JSON.pretty_generate(docker))
|
160
|
+
image
|
161
|
+
end
|
162
|
+
|
154
163
|
def autodetect_app_role env
|
155
164
|
enabled = @options[:autodetect_app_role]
|
156
165
|
if enabled == true || enabled == "true"
|
157
166
|
role = env.split('-')[2]
|
158
167
|
puts "Deploying app as a #{role}"
|
159
|
-
#role_cmd = IO.read("roles/#{role}").gsub("\n",'')
|
160
|
-
#docker = JSON.parse(IO.read(@dockerrun_file))
|
161
|
-
#docker["Cmd"] = role_cmd
|
162
|
-
#IO.write(@dockerrun_file,JSON.pretty_generate(docker))
|
163
|
-
#puts "Setting role cmd to '#{role_cmd}'"
|
164
168
|
[{:option_name => "ROLE", :value => role, :namespace => "aws:elasticbeanstalk:application:environment" }]
|
165
169
|
else
|
166
170
|
[]
|
data/lib/gantree/docker.rb
CHANGED
@@ -7,18 +7,17 @@ module Gantree
|
|
7
7
|
check_credentials
|
8
8
|
set_aws_keys
|
9
9
|
@options = options
|
10
|
-
@
|
11
|
-
raise "Please provide
|
12
|
-
@repo = `basename $(git rev-parse --show-toplevel)`.strip
|
10
|
+
@image_path = @options[:image_path]
|
11
|
+
raise "Please provide an image path name in .gantreecfg ex. { 'image_path' : 'bleacher/cms' }" unless @image_path
|
13
12
|
@tag = @options[:tag] ||= tag
|
14
13
|
end
|
15
14
|
|
16
15
|
def build
|
17
16
|
puts "Building..."
|
18
|
-
output = `docker build -t #{@
|
17
|
+
output = `docker build -t #{@image_path}:#{@tag} .`
|
19
18
|
if $?.success?
|
20
|
-
puts "Image Built: #{@
|
21
|
-
puts "
|
19
|
+
puts "Image Built: #{@image_path}:#{@tag}".green
|
20
|
+
puts "gantree push --image-path #{@image_path} -t #{@tag}" unless @options[:hush]
|
22
21
|
puts "gantree deploy app_name -t #{@tag}" unless @options[:hush]
|
23
22
|
else
|
24
23
|
puts "Error: Image was not built successfully".red
|
@@ -28,10 +27,10 @@ module Gantree
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def push
|
31
|
-
puts "Pushing..."
|
32
|
-
output = `docker push #{@
|
30
|
+
puts "Pushing to #{@image_path}:#{@tag} ..."
|
31
|
+
output = `docker push #{@image_path}:#{@tag}`
|
33
32
|
if $?.success?
|
34
|
-
puts "Image Pushed: #{@
|
33
|
+
puts "Image Pushed: #{@image_path}:#{@tag}".green
|
35
34
|
puts "gantree deploy app_name -t #{@tag}" unless @options[:hush]
|
36
35
|
else
|
37
36
|
puts "Error: Image was not pushed successfully".red
|
data/lib/gantree/stack.rb
CHANGED
@@ -103,7 +103,7 @@ module Gantree
|
|
103
103
|
def replace_env_references file
|
104
104
|
origin_tags = @options[:dupe].split("-")
|
105
105
|
new_tags = @options[:stack_name].split("-")
|
106
|
-
possible_roles = ["app","worker","listener","djay","scheduler"]
|
106
|
+
possible_roles = ["app","worker","listener","djay","scheduler","sched"]
|
107
107
|
possible_roles.each do |role|
|
108
108
|
origin_env = [origin_tags[1],origin_tags[0],role,origin_tags[2]].join('-')
|
109
109
|
new_env = [new_tags[1],new_tags[0],role,new_tags[2]].join('-')
|
data/lib/gantree/version.rb
CHANGED
@@ -44,6 +44,13 @@ describe Gantree::Deploy do
|
|
44
44
|
gd.set_aws_keys
|
45
45
|
end
|
46
46
|
|
47
|
+
it "the image path is dynamic" do
|
48
|
+
options = { image_path: "quay.io/bleacherreport/cms" }
|
49
|
+
deploy = Gantree::Deploy.new(@env,options)
|
50
|
+
image_path = deploy.instance_variable_get("@options")[:image_path]
|
51
|
+
expect(image_path).to eq("quay.io/bleacherreport/cms")
|
52
|
+
end
|
53
|
+
|
47
54
|
it "raises an error when no aws keys in ENV" do
|
48
55
|
ENV['AWS_ACCESS_KEY_ID'] = nil
|
49
56
|
ENV['AWS_SECRET_ACCESS_KEY'] = nil
|
@@ -54,3 +61,20 @@ describe Gantree::Deploy do
|
|
54
61
|
end
|
55
62
|
end
|
56
63
|
|
64
|
+
def dockerrun
|
65
|
+
'
|
66
|
+
{
|
67
|
+
"AWSEBDockerrunVersion": "1",
|
68
|
+
"Image": {
|
69
|
+
"Name": "bleacher/cms",
|
70
|
+
"Update": true
|
71
|
+
},
|
72
|
+
"Logging": "/var/log/nginx",
|
73
|
+
"Ports": [
|
74
|
+
{
|
75
|
+
"ContainerPort": "300"
|
76
|
+
}
|
77
|
+
]
|
78
|
+
}
|
79
|
+
'
|
80
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "pry"
|
3
|
+
|
4
|
+
describe Gantree::Docker do
|
5
|
+
before(:all) do
|
6
|
+
ENV['AWS_ACCESS_KEY_ID'] = 'FAKE_AWS_ACCESS_KEY'
|
7
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = 'FAKE_AWS_SECRET_ACCESS_KEY'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "requires an image_path option to be set"
|
11
|
+
it "generates a unique tag for you"
|
12
|
+
it "allows you to set your own tag to build"
|
13
|
+
it "allows you to set your own tag to push"
|
14
|
+
it "builds dockerfiles with tag"
|
15
|
+
it "accepts image path parameter"
|
16
|
+
it "pushes tag to dockerhub"
|
17
|
+
|
18
|
+
end
|
19
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gantree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -283,6 +283,7 @@ files:
|
|
283
283
|
- lib/gantree/version.rb
|
284
284
|
- spec/lib/gantree/cli_spec.rb
|
285
285
|
- spec/lib/gantree/deploy_spec.rb
|
286
|
+
- spec/lib/gantree/docker_spec.rb
|
286
287
|
- spec/lib/gantree/init_spec.rb
|
287
288
|
- spec/lib/gantree/stack_spec.rb
|
288
289
|
- spec/spec_helper.rb
|
@@ -316,6 +317,7 @@ summary: This tool is intended to help you setup a Dockerrun.aws.json which allo
|
|
316
317
|
test_files:
|
317
318
|
- spec/lib/gantree/cli_spec.rb
|
318
319
|
- spec/lib/gantree/deploy_spec.rb
|
320
|
+
- spec/lib/gantree/docker_spec.rb
|
319
321
|
- spec/lib/gantree/init_spec.rb
|
320
322
|
- spec/lib/gantree/stack_spec.rb
|
321
323
|
- spec/spec_helper.rb
|