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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e2ede56c490aa668c0d17af629f8d095314b6ad
4
- data.tar.gz: a565762fba4e21a5c310e277e706dd7e4c5608b8
3
+ metadata.gz: 199f498599a6374fa1b2284831eee49fe875ff62
4
+ data.tar.gz: 4b1541a027c16b5d2880d38d39cc085649bf2f13
5
5
  SHA512:
6
- metadata.gz: 3a10a1125890cbc0670f478c38401b4c4b9aab06edee38c3066c443bf93f62c476a964d393ce6cf59157f6c445a27cb6c943b649f8980ea2444ad336a0a65fdd
7
- data.tar.gz: 7ea1841019fbc871bb435929ad322b907ea1132611075b881a9e6df7afe070e55aab8f8b748b9efa9b567dd9e84bc9dd3e75b6c3092b42530ebadb0147ac9aca
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
- 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.production ."
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 { |c| run c } # TODO: check that this succeeded
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 { |c| run c } # TODO: check that this succeeded
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}" # TODO: check that this succeeded
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
@@ -1,3 +1,3 @@
1
1
  module Shiprails
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.14"
3
3
  end
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.13
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-02 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport