shiprails 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shiprails/ship/deploy.rb +31 -5
- data/lib/shiprails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 199f498599a6374fa1b2284831eee49fe875ff62
|
4
|
+
data.tar.gz: 4b1541a027c16b5d2880d38d39cc085649bf2f13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bec3817f21f519c608486a463fd2c7364d09e55a30548a1b397fd8f99a46a8c0f23cfc09dc22ac44496c02a52f647754b8eb3b6acf3abb6985f3ecd285eccf55
|
7
|
+
data.tar.gz: 56cb41cf6eb9a30c04bad41c449279cae65e61760defe79b59e20549f1c6d0ee8219f4aaf83323de7bbbb8c0b937791cdd45307bd27e8b4e5433abd3bcc3acae
|
@@ -33,12 +33,32 @@ module Shiprails
|
|
33
33
|
s3 = Aws::S3::Client.new(region: region_name.to_s)
|
34
34
|
objects = s3.list_objects_v2(bucket: s3_config_bucket, prefix: environment_name)
|
35
35
|
s3_config_revision = objects.contents.map{ |object| object.key[/\d+/].to_i }.max || 0
|
36
|
-
|
36
|
+
ecr = Aws::ECR::Client.new({ region: region_name.to_s })
|
37
|
+
authorization_data = ecr.get_authorization_token.authorization_data.first
|
38
|
+
credentials = Base64.decode64(authorization_data.authorization_token).split(':')
|
39
|
+
exit(1) unless run "docker login -u #{credentials.first} -p #{credentials.last} -e none #{authorization_data.proxy_endpoint}"
|
40
|
+
repository_name = region[:repository_url].split('/').drop(1).join('/')
|
41
|
+
images = ecr.describe_images(repository_name: repository_name).image_details
|
42
|
+
tags = images.map(&:image_tags).flatten
|
43
|
+
shas = git.log(1000).map(&:sha) # get last 1000 commits
|
44
|
+
last_built_sha = nil
|
45
|
+
shas.each do |sha|
|
46
|
+
if tags.include?(sha)
|
47
|
+
last_built_sha = sha
|
48
|
+
break
|
49
|
+
end
|
50
|
+
end
|
51
|
+
unless last_built_sha.nil?
|
52
|
+
exit(1) unless run "docker pull #{region[:repository_url]}:#{last_built_sha}"
|
53
|
+
end
|
54
|
+
commands << "docker build -t #{image_name}_#{environment_name} --build-arg AWS_ACCESS_KEY_ID='#{aws_access_key_id}' --build-arg AWS_SECRET_ACCESS_KEY='#{aws_access_key_secret}' --build-arg AWS_REGION='#{region_name.to_s}' --build-arg S3_CONFIG_BUCKET='#{s3_config_bucket}' --build-arg S3_CONFIG_ENVIRONMENT='#{environment_name}' --build-arg S3_CONFIG_REVISION='#{s3_config_revision}' -f #{dockerfile_path} ."
|
37
55
|
end
|
38
56
|
end
|
39
57
|
end
|
40
58
|
commands.uniq!
|
41
|
-
commands.each
|
59
|
+
commands.each do |c|
|
60
|
+
exit(1) unless run c
|
61
|
+
end
|
42
62
|
say "Build complete", :green
|
43
63
|
end
|
44
64
|
|
@@ -56,7 +76,9 @@ module Shiprails
|
|
56
76
|
end
|
57
77
|
end
|
58
78
|
commands.uniq!
|
59
|
-
commands.each
|
79
|
+
commands.each do |c|
|
80
|
+
exit(1) unless run c
|
81
|
+
end
|
60
82
|
say "Tagging complete.", :green
|
61
83
|
end
|
62
84
|
|
@@ -72,8 +94,8 @@ module Shiprails
|
|
72
94
|
ecr = Aws::ECR::Client.new({ region: region.to_s })
|
73
95
|
authorization_data = ecr.get_authorization_token.authorization_data.first
|
74
96
|
credentials = Base64.decode64(authorization_data.authorization_token).split(':')
|
75
|
-
run "docker login -u #{credentials.first} -p #{credentials.last} -e none #{authorization_data.proxy_endpoint}"
|
76
|
-
run "docker push #{repository_url}:#{git_sha}"
|
97
|
+
exit(1) unless run "docker login -u #{credentials.first} -p #{credentials.last} -e none #{authorization_data.proxy_endpoint}"
|
98
|
+
exit(1) unless run "docker push #{repository_url}:#{git_sha}"
|
77
99
|
end
|
78
100
|
say "Push complete.", :green
|
79
101
|
end
|
@@ -177,6 +199,10 @@ module Shiprails
|
|
177
199
|
YAML.load(File.read("#{options[:path]}/.shiprails.yml")).deep_symbolize_keys
|
178
200
|
end
|
179
201
|
|
202
|
+
def dockerfile_path
|
203
|
+
configuration[:dockerfile_path] || "Dockerfile.production"
|
204
|
+
end
|
205
|
+
|
180
206
|
def git
|
181
207
|
@_git ||= Git.open(Dir.getwd)
|
182
208
|
end
|
data/lib/shiprails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shiprails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zane Shannon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|