shiprails 0.1.14 → 0.1.16

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: 199f498599a6374fa1b2284831eee49fe875ff62
4
- data.tar.gz: 4b1541a027c16b5d2880d38d39cc085649bf2f13
3
+ metadata.gz: 56ad943e3c31dce558f301d17f74d3fe9ee8fd66
4
+ data.tar.gz: 78cb95e986707c421b314be374cddd56c36d9d4e
5
5
  SHA512:
6
- metadata.gz: bec3817f21f519c608486a463fd2c7364d09e55a30548a1b397fd8f99a46a8c0f23cfc09dc22ac44496c02a52f647754b8eb3b6acf3abb6985f3ecd285eccf55
7
- data.tar.gz: 56cb41cf6eb9a30c04bad41c449279cae65e61760defe79b59e20549f1c6d0ee8219f4aaf83323de7bbbb8c0b937791cdd45307bd27e8b4e5433abd3bcc3acae
6
+ metadata.gz: 443405a53e8790d41e9df6c24bc08d8ff7d39b16b10804723af482271a7a4d7853c41924674d7056a8709ffe7e28cb74244a2fa8063355b85bb8582a3ab2c324
7
+ data.tar.gz: 7402c82fcb9ace723ef6fa623b7e9faf9087d008de371e1c58dc03e3e9c79bd28c2724c47c2fca1c18159c5673c8a49a3017a5d4bd2922a19503cf8737019085
@@ -22,6 +22,7 @@ module Shiprails
22
22
  end
23
23
 
24
24
  def build_docker_images
25
+ perform_callbacks :before_build_docker_images
25
26
  say "Building images..."
26
27
  s3_config_bucket = configuration[:config_s3_bucket].to_s
27
28
  commands = []
@@ -36,7 +37,7 @@ module Shiprails
36
37
  ecr = Aws::ECR::Client.new({ region: region_name.to_s })
37
38
  authorization_data = ecr.get_authorization_token.authorization_data.first
38
39
  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
+ exit(1) unless run "docker login -u #{credentials.first} -p #{credentials.last} #{authorization_data.proxy_endpoint}"
40
41
  repository_name = region[:repository_url].split('/').drop(1).join('/')
41
42
  images = ecr.describe_images(repository_name: repository_name).image_details
42
43
  tags = images.map(&:image_tags).flatten
@@ -60,9 +61,11 @@ module Shiprails
60
61
  exit(1) unless run c
61
62
  end
62
63
  say "Build complete", :green
64
+ perform_callbacks :after_build_docker_images
63
65
  end
64
66
 
65
67
  def tag_docker_images
68
+ perform_callbacks :before_tag_docker_images
66
69
  say "Tagging images..."
67
70
  commands = []
68
71
  configuration[:services].each do |service_name, service|
@@ -80,9 +83,11 @@ module Shiprails
80
83
  exit(1) unless run c
81
84
  end
82
85
  say "Tagging complete.", :green
86
+ perform_callbacks :after_tag_docker_images
83
87
  end
84
88
 
85
89
  def push_docker_images
90
+ perform_callbacks :before_push_docker_images
86
91
  say "Pushing images..."
87
92
  repository_urls_to_regions = {}
88
93
  configuration[:services].each do |service_name, service|
@@ -94,13 +99,15 @@ module Shiprails
94
99
  ecr = Aws::ECR::Client.new({ region: region.to_s })
95
100
  authorization_data = ecr.get_authorization_token.authorization_data.first
96
101
  credentials = Base64.decode64(authorization_data.authorization_token).split(':')
97
- exit(1) unless run "docker login -u #{credentials.first} -p #{credentials.last} -e none #{authorization_data.proxy_endpoint}"
102
+ exit(1) unless run "docker login -u #{credentials.first} -p #{credentials.last} #{authorization_data.proxy_endpoint}"
98
103
  exit(1) unless run "docker push #{repository_url}:#{git_sha}"
99
104
  end
100
105
  say "Push complete.", :green
106
+ perform_callbacks :after_push_docker_images
101
107
  end
102
108
 
103
109
  def update_ecs_tasks
110
+ perform_callbacks :before_update_ecs_tasks
104
111
  say "Updating ECS tasks..."
105
112
  configuration[:services].each do |service_name, service|
106
113
  image_name = "#{project_name}_#{service_name}"
@@ -144,9 +151,11 @@ module Shiprails
144
151
  end
145
152
  end
146
153
  say "ECS tasks updated.", :green
154
+ perform_callbacks :after_update_ecs_tasks
147
155
  end
148
156
 
149
157
  def update_ecs_services
158
+ perform_callbacks :before_update_ecs_services
150
159
  say "Updating ECS services..."
151
160
  configuration[:services].each do |service_name, service|
152
161
  service[:regions].each do |region_name, region|
@@ -179,6 +188,7 @@ module Shiprails
179
188
  end
180
189
  end
181
190
  say "ECS services updated.", :green
191
+ perform_callbacks :after_update_ecs_services
182
192
  end
183
193
 
184
194
  def done
@@ -203,6 +213,10 @@ module Shiprails
203
213
  configuration[:dockerfile_path] || "Dockerfile.production"
204
214
  end
205
215
 
216
+ def environment
217
+ args.first
218
+ end
219
+
206
220
  def git
207
221
  @_git ||= Git.open(Dir.getwd)
208
222
  end
@@ -223,6 +237,17 @@ module Shiprails
223
237
  configuration[:config_s3_bucket]
224
238
  end
225
239
 
240
+ def perform_callbacks(stage_name)
241
+ @_callbacks ||= configuration[:callbacks] || {}
242
+ if @_callbacks.key?(stage_name)
243
+ command = @_callbacks[stage_name]
244
+ wrapped_command = "ship exec -e #{environment} #{command}"
245
+ say "#{stage_name.to_s}: #{wrapped_command}"
246
+ result = run(wrapped_command)
247
+ exit(1) unless result
248
+ end
249
+ end
250
+
226
251
  end
227
252
  end
228
253
  end
@@ -162,7 +162,7 @@ module Shiprails
162
162
  # sleep 5 # AWS just needs a little bit to setup networking
163
163
  say "Connecting #{ssh_user}@#{ec2_instance.public_ip_address}..."
164
164
  say "Executing: $ #{command_string}"
165
- system "ssh -o ConnectTimeout=15 -o 'StrictHostKeyChecking no' -t -i #{ssh_private_key_path} #{ssh_user}@#{ec2_instance.public_ip_address} '#{command_string}'"
165
+ system "ssh -o ConnectTimeout=15 -o 'StrictHostKeyChecking no' -t -i #{ssh_private_key_path} #{ssh_user}@#{ec2_instance.public_ip_address} '`aws ecr get-login --region #{region}` && #{command_string}'"
166
166
  rescue => e
167
167
  puts e.inspect
168
168
  say "Error: #{e.message}", :red
@@ -1,3 +1,3 @@
1
1
  module Shiprails
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.16"
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.14
4
+ version: 0.1.16
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-07 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport