eb-docker-deploy 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/eb-docker-deploy.gemspec +2 -0
- data/lib/deploy.rb +2 -0
- data/lib/deploy/deployer.rb +17 -26
- data/lib/deploy/docker_hub_api.rb +15 -0
- data/lib/deploy/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c85a599060b7de1e5b98586206cf0fbb9daf3a9
|
4
|
+
data.tar.gz: 922128fc059e9d63ee6e57afefaf72ececf1693e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f11e93101de17d7201f6752546e7c6175eda380fa5a757df90d6a28104bd5c728f33adbb1a61277d5c594e22edd3bb674fe3e4d4f43527a15d0752fb1aba8812
|
7
|
+
data.tar.gz: f85183284ae14d547993b60c0fd6e5ae15829c8dea149b691e4570e41b24648430988882cd8c5580792d8a72d4d0ab66efdab53582517238927d651e6cca58c0
|
data/eb-docker-deploy.gemspec
CHANGED
data/lib/deploy.rb
CHANGED
data/lib/deploy/deployer.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
module Deploy
|
2
2
|
class Deployer < Thor
|
3
3
|
include Deploy::Output
|
4
|
+
include DockerHubApi
|
4
5
|
|
5
6
|
desc 'setup config', 'setup config'
|
6
7
|
def setup
|
7
|
-
|
8
|
+
# setup aws config
|
9
|
+
|
10
|
+
(shout('AWS creds already configured at ~/.aws/config'); exit(1)) if File.exist?(File.expand_path('~/.aws/config'))
|
8
11
|
|
9
12
|
key = ask('Enter AWS Key:')
|
10
13
|
secret = ask('Enter AWS Secret:')
|
@@ -16,25 +19,30 @@ module Deploy
|
|
16
19
|
f.puts "aws_access_key_id = #{key}"
|
17
20
|
f.puts "aws_secret_access_key = #{secret}"
|
18
21
|
end
|
19
|
-
shout('AWS creds successfully configured at ~/.aws/config
|
22
|
+
shout('AWS creds successfully configured at ~/.aws/config') if File.exist?(File.expand_path('~/.aws/config'))
|
23
|
+
|
24
|
+
# setup docker hub creds
|
25
|
+
(shout('Docker Hub creds already configured at ~/.docker/config.json'); exit(1)) if File.exist?(File.expand_path('~/.docker/config.json'))
|
26
|
+
command = "docker login"
|
27
|
+
exit(1) unless system(command)
|
20
28
|
end
|
21
29
|
|
22
30
|
method_option :version, aliases: '-v', desc: 'Version'
|
23
31
|
method_option :environment, aliases: '-e', desc: 'Environment'
|
24
|
-
method_option :
|
32
|
+
method_option :no_build, aliases: '--no-build', desc: 'Do not Build Image'
|
25
33
|
desc 'deploy', 'deploy'
|
26
34
|
def deploy
|
27
35
|
check_setup
|
28
36
|
|
29
37
|
environment = options[:environment]
|
30
|
-
|
38
|
+
no_build = options[:no_build]
|
31
39
|
|
32
40
|
version = options[:version]
|
33
41
|
check_version(version)
|
34
42
|
|
35
43
|
repo = ENV['DOCKER_REPO']
|
36
44
|
|
37
|
-
if
|
45
|
+
if !no_build
|
38
46
|
announce({ color: '#6080C0', title: "Deployment started with build", text: "Deploying version #{version} to #{environment || 'stage'}" })
|
39
47
|
build_image(repo, version)
|
40
48
|
|
@@ -47,7 +55,6 @@ module Deploy
|
|
47
55
|
end
|
48
56
|
|
49
57
|
run_deploy(version, environment)
|
50
|
-
record_version(version)
|
51
58
|
announce({ color: 'good', title: 'Deployment Succeeded!!', text: "The current version of #{environment || 'stage'} is #{version}" })
|
52
59
|
end
|
53
60
|
|
@@ -72,7 +79,6 @@ module Deploy
|
|
72
79
|
push_image(repo, 'latest')
|
73
80
|
|
74
81
|
run_rollback(version, environment)
|
75
|
-
record_version(version)
|
76
82
|
announce({ color: 'good', title: 'Rollback Succeeded!!', text: "The current version of #{environment || 'stage'} is #{version}" })
|
77
83
|
end
|
78
84
|
|
@@ -83,6 +89,8 @@ module Deploy
|
|
83
89
|
|
84
90
|
desc 'list versions', 'list versions'
|
85
91
|
def versions
|
92
|
+
check_setup
|
93
|
+
|
86
94
|
versions_array.each do |v|
|
87
95
|
shout v
|
88
96
|
end
|
@@ -147,6 +155,7 @@ module Deploy
|
|
147
155
|
(shout('eb command not installed'); exit(1)) unless command?('eb')
|
148
156
|
(shout('elasticbeanstalk not configured for this project. run "eb init".'); exit(1)) unless File.exist?('.elasticbeanstalk')
|
149
157
|
(shout('AWS credentials not configured.'); exit(1)) unless File.exist?(File.expand_path('~/.aws/config'))
|
158
|
+
(shout('Docker Hub credentials not configured.'); exit(1)) unless File.exist?(File.expand_path('~/.docker/config.json'))
|
150
159
|
(shout('ENV DOCKER_REPO not set'); exit(1)) unless ENV['DOCKER_REPO']
|
151
160
|
end
|
152
161
|
|
@@ -164,30 +173,12 @@ module Deploy
|
|
164
173
|
(shout('You are currently on that version'); exit(1)) if current_version == version
|
165
174
|
end
|
166
175
|
|
167
|
-
def record_version(version)
|
168
|
-
write_to_versions_file(versions_array.push(version))
|
169
|
-
end
|
170
|
-
|
171
176
|
def current_version
|
172
177
|
versions_array.last
|
173
178
|
end
|
174
179
|
|
175
180
|
def versions_array
|
176
|
-
|
177
|
-
end
|
178
|
-
|
179
|
-
def write_to_versions_file(new_array)
|
180
|
-
write_versions_file do |f|
|
181
|
-
new_array.each { |v| f.puts(v) }
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
def write_versions_file(&block)
|
186
|
-
File.open('.versions', 'w+', &block)
|
187
|
-
end
|
188
|
-
|
189
|
-
def read_versions_file
|
190
|
-
File.open('.versions', 'r')
|
181
|
+
get("/v1/repositories/#{ENV['DOCKER_REPO']}/tags").map { |tag| tag['name'] }
|
191
182
|
end
|
192
183
|
|
193
184
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DockerHubApi
|
2
|
+
|
3
|
+
ROOT_PATH = 'https://registry.hub.docker.com'
|
4
|
+
|
5
|
+
def get(url)
|
6
|
+
body = RestClient.get("#{ROOT_PATH}#{url}", { Authorization: "Basic #{get_token}" }).body
|
7
|
+
JSON.parse(body)
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_token
|
11
|
+
auths_hash = JSON.parse(File.open(File.expand_path('~/.docker/config.json')).read)['auths']
|
12
|
+
docker_hub_token = auths_hash['https://index.docker.io/v1/']['auth']
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/deploy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eb-docker-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rest-client
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: slack-notifier
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,6 +113,7 @@ files:
|
|
99
113
|
- eb-docker-deploy.gemspec
|
100
114
|
- lib/deploy.rb
|
101
115
|
- lib/deploy/deployer.rb
|
116
|
+
- lib/deploy/docker_hub_api.rb
|
102
117
|
- lib/deploy/output.rb
|
103
118
|
- lib/deploy/version.rb
|
104
119
|
homepage: ''
|