ufo 3.4.3 → 3.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +4 -0
- data/lib/template/.ufo/templates/fargate.json.erb +1 -1
- data/lib/template/.ufo/templates/main.json.erb +1 -1
- data/lib/ufo/docker/builder.rb +31 -1
- data/lib/ufo/docker/pusher.rb +3 -1
- data/lib/ufo/ecr/auth.rb +3 -0
- data/lib/ufo/param.rb +17 -0
- data/lib/ufo/ship.rb +28 -21
- data/lib/ufo/tasks/register.rb +8 -1
- data/lib/ufo/upgrade/params.yml +1 -1
- data/lib/ufo/version.rb +1 -1
- data/spec/fixtures/dockerfiles/dockerhub/Dockerfile +1 -0
- data/spec/fixtures/dockerfiles/ecr/Dockerfile +1 -0
- data/spec/lib/builder_spec.rb +23 -0
- metadata +8 -3
- data/lib/ufo/deploy.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53201d5487d8074486f75afc6e14e3078240714b721e84f32405c41a8fe64b16
|
4
|
+
data.tar.gz: 546cfdd56445e30f6c2791970fa9ad04921075895ba1bee7601f7570d2b06873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 030546c273054b55929bf1d0f22ff4602a122985dd90757ee45dabc1cf2dbaca605236231c9fd195172121b49364d38efd44a730be65e00379341b718ddda24d
|
7
|
+
data.tar.gz: 4a072047fa10c03bafae95f8f8eb9e3d73197c924615fbe77058906e9480b7e60cc1d492ed645c9eb132e78a2812491f0cfbc822d744c5b29ba32dec6acf512f
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [3.4.4]
|
7
|
+
- Merge pull request #34 from tongueroo/show-aws-cli-commands
|
8
|
+
- Show equivalent cli commands when possible
|
9
|
+
- Automatically auth ECR when Dockerfiles has ECR image in FROM instruction
|
10
|
+
- Fix upgrade task and provide user with warning message for 3.4.x version.
|
11
|
+
|
6
12
|
## [3.4.3]
|
7
13
|
- remove debugging puts
|
8
14
|
|
data/README.md
CHANGED
@@ -56,3 +56,7 @@ Congratulations, you have successfully used ufo to deploy to an ECS service.
|
|
56
56
|
## Contributing
|
57
57
|
|
58
58
|
Bug reports and pull requests are welcome on GitHub at [https://github.com/tongueroo/ufo/issues](https://github.com/tongueroo/ufo/issues).
|
59
|
+
|
60
|
+
### QA Checklist
|
61
|
+
|
62
|
+
[QA Checklist](https://github.com/tongueroo/ufo/wiki/QA-Checklist) is a good list of things to check.
|
data/lib/ufo/docker/builder.rb
CHANGED
@@ -23,6 +23,8 @@ class Ufo::Docker
|
|
23
23
|
start_time = Time.now
|
24
24
|
store_full_image_name
|
25
25
|
|
26
|
+
update_auth_token
|
27
|
+
|
26
28
|
command = "docker build -t #{full_image_name} -f #{@dockerfile} ."
|
27
29
|
say "Building docker image with:".green
|
28
30
|
say " #{command}".green
|
@@ -38,6 +40,32 @@ class Ufo::Docker
|
|
38
40
|
say "Docker image #{full_image_name} built. " + "Took #{pretty_time(took)}.".green
|
39
41
|
end
|
40
42
|
|
43
|
+
# Parse Dockerfile for FROM instruction. If the starting image is from an ECR
|
44
|
+
# repository, it's likely an private image so we authorize ECR for pulling.
|
45
|
+
def update_auth_token
|
46
|
+
ecr_image_names = ecr_image_names("#{Ufo.root}/#{@dockerfile}")
|
47
|
+
return if ecr_image_names.empty?
|
48
|
+
|
49
|
+
ecr_image_names.each do |ecr_image_name|
|
50
|
+
auth = Ufo::Ecr::Auth.new(ecr_image_name)
|
51
|
+
# wont update auth token unless the image being pushed in the ECR image format
|
52
|
+
auth.update
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def ecr_image_names(path)
|
57
|
+
from_image_names(path).select { |i| i =~ /\.amazonaws\.com/ }
|
58
|
+
end
|
59
|
+
|
60
|
+
def from_image_names(path)
|
61
|
+
lines = IO.readlines(path)
|
62
|
+
froms = lines.select { |l| l =~ /^FROM/ }
|
63
|
+
froms.map do |l|
|
64
|
+
md = l.match(/^FROM (.*)/)
|
65
|
+
md[1]
|
66
|
+
end.compact
|
67
|
+
end
|
68
|
+
|
41
69
|
def pusher
|
42
70
|
@pusher ||= Pusher.new(full_image_name, @options)
|
43
71
|
end
|
@@ -54,7 +82,9 @@ class Ufo::Docker
|
|
54
82
|
settings["image"]
|
55
83
|
end
|
56
84
|
|
57
|
-
# full_image -
|
85
|
+
# full_image - Includes the tag. Examples:
|
86
|
+
# 123456789.dkr.ecr.us-west-2.amazonaws.com/myapp:ufo-2018-04-20T09-29-08-b7d51df
|
87
|
+
# tongueroo/hi:ufo-2018-04-20T09-29-08-b7d51df
|
58
88
|
def full_image_name
|
59
89
|
return generate_name if @options[:generate]
|
60
90
|
return "tongueroo/hi:ufo-12345678" if ENV['TEST']
|
data/lib/ufo/docker/pusher.rb
CHANGED
@@ -8,6 +8,8 @@ class Ufo::Docker
|
|
8
8
|
attr_reader :last_image_name
|
9
9
|
def initialize(image, options)
|
10
10
|
@options = options
|
11
|
+
# full_image_name ultimately uses @options, so @last_image_name assignment
|
12
|
+
# line must be defined after setting @options.
|
11
13
|
@last_image_name = image || full_image_name
|
12
14
|
end
|
13
15
|
|
@@ -38,7 +40,7 @@ class Ufo::Docker
|
|
38
40
|
def update_auth_token
|
39
41
|
auth = Ufo::Ecr::Auth.new(last_image_name)
|
40
42
|
# wont update auth token unless the image being pushed in the ECR image format
|
41
|
-
auth.update
|
43
|
+
auth.update
|
42
44
|
end
|
43
45
|
|
44
46
|
# full_image - does not include the tag
|
data/lib/ufo/ecr/auth.rb
CHANGED
data/lib/ufo/param.rb
CHANGED
@@ -15,10 +15,27 @@ module Ufo
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def data
|
18
|
+
upgrade_message!
|
19
|
+
|
18
20
|
vars = Ufo::TemplateScope.new(helper).assign_instance_variables
|
19
21
|
result = RenderMePretty.result(@params_path, vars)
|
20
22
|
YAML.load(result)
|
21
23
|
end
|
22
24
|
memoize :data
|
25
|
+
|
26
|
+
# Ufo version 3.3 to 3.4 added a concept of a .ufo/params.yml file to support
|
27
|
+
# fargate: https://github.com/tongueroo/ufo/pull/31
|
28
|
+
#
|
29
|
+
# Warn user and tell them to run the `ufo upgrade3_3_to_3_4` command to upgrade.
|
30
|
+
def upgrade_message!
|
31
|
+
return if File.exist?(@params_path)
|
32
|
+
|
33
|
+
puts "ERROR: Your project is missing the .ufo/params.yml.".colorize(:red)
|
34
|
+
puts "This was added in ufo version 3.4 for Fargate support: https://github.com/tongueroo/ufo/pull/31"
|
35
|
+
puts "You can find more info about the params file here: http://ufoships.com/docs/params/"
|
36
|
+
puts "To upgrade run:"
|
37
|
+
puts " ufo upgrade3_3_to_3_4"
|
38
|
+
exit 1
|
39
|
+
end
|
23
40
|
end
|
24
41
|
end
|
data/lib/ufo/ship.rb
CHANGED
@@ -125,25 +125,6 @@ module Ufo
|
|
125
125
|
[deployed_service.service_name, took]
|
126
126
|
end
|
127
127
|
|
128
|
-
def wait_for_all_deployments(deployed_services)
|
129
|
-
start_time = Time.now
|
130
|
-
threads = deployed_services.map do |deployed_service|
|
131
|
-
Thread.new do
|
132
|
-
# http://stackoverflow.com/questions/1383390/how-can-i-return-a-value-from-a-thread-in-ruby
|
133
|
-
Thread.current[:output] = wait_for_deployment(deployed_service, quiet=true)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
threads.each { |t| t.join }
|
137
|
-
total_took = Time.now - start_time
|
138
|
-
puts ""
|
139
|
-
puts "Shipments for all #{deployed_service.size} services took a total of #{pretty_time(total_took).green}."
|
140
|
-
puts "Each deployment took:"
|
141
|
-
threads.each do |t|
|
142
|
-
service_name, took = t[:output]
|
143
|
-
puts " #{service_name}: #{pretty_time(took)}"
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
128
|
# used for polling
|
148
129
|
# must pass in a service and cannot use @service for the case of multi_services mode
|
149
130
|
def find_updated_service(service)
|
@@ -214,15 +195,35 @@ module Ufo
|
|
214
195
|
unless target_group.nil? || target_group.empty?
|
215
196
|
add_load_balancer!(container, options, target_group)
|
216
197
|
end
|
198
|
+
|
217
199
|
puts "Creating ECS service with params:"
|
218
200
|
display_params(options)
|
201
|
+
show_aws_cli_command(:create, options)
|
219
202
|
response = ecs.create_service(options)
|
220
203
|
service = response.service # must set service here since this might never be called if @wait_for_deployment is false
|
221
204
|
end
|
205
|
+
|
222
206
|
puts message unless @options[:mute]
|
223
207
|
service
|
224
208
|
end
|
225
209
|
|
210
|
+
def show_aws_cli_command(action, params)
|
211
|
+
puts "Equivalent aws cli command:"
|
212
|
+
# Use .ufo/data instead of .ufo/output because output files all get looped
|
213
|
+
# through as part of `ufo tasks register`
|
214
|
+
rel_path = ".ufo/data/#{action}-params.json"
|
215
|
+
output_path = "#{Ufo.root}/#{rel_path}"
|
216
|
+
FileUtils.rm_f(output_path)
|
217
|
+
|
218
|
+
# Thanks: https://www.mnishiguchi.com/2017/11/29/rails-hash-camelize-and-underscore-keys/
|
219
|
+
params = params.deep_transform_keys { |key| key.to_s.camelize(:lower) }
|
220
|
+
json = JSON.pretty_generate(params)
|
221
|
+
IO.write(output_path, json)
|
222
|
+
|
223
|
+
file_path = "file://#{rel_path}"
|
224
|
+
puts " aws ecs #{action}-service --cli-input-json #{file_path}".colorize(:green)
|
225
|
+
end
|
226
|
+
|
226
227
|
# $ aws ecs update-service --generate-cli-skeleton
|
227
228
|
# {
|
228
229
|
# "cluster": "",
|
@@ -248,9 +249,14 @@ module Ufo
|
|
248
249
|
params = params.merge(default_params[:update_service] || {})
|
249
250
|
puts "Updating ECS service with params:"
|
250
251
|
display_params(params)
|
251
|
-
|
252
|
-
|
252
|
+
show_aws_cli_command(:update, params)
|
253
|
+
|
254
|
+
unless @options[:noop]
|
255
|
+
response = ecs.update_service(params)
|
256
|
+
service = response.service # must set service here since this might never be called if @wait_for_deployment is false
|
257
|
+
end
|
253
258
|
end
|
259
|
+
|
254
260
|
puts message unless @options[:mute]
|
255
261
|
service
|
256
262
|
end
|
@@ -366,6 +372,7 @@ module Ufo
|
|
366
372
|
# TODO: Aad Waiter logic, sometimes the cluster does not exist by the time
|
367
373
|
# we create the service
|
368
374
|
end
|
375
|
+
|
369
376
|
puts message unless @options[:mute]
|
370
377
|
end
|
371
378
|
end
|
data/lib/ufo/tasks/register.rb
CHANGED
@@ -24,13 +24,20 @@ module Ufo
|
|
24
24
|
def register
|
25
25
|
data = JSON.parse(IO.read(@template_definition_path))
|
26
26
|
data = rubyize_format(data)
|
27
|
+
|
27
28
|
message = "#{data[:family]} task definition registered."
|
28
29
|
if @options[:noop]
|
29
30
|
message = "NOOP: #{message}"
|
30
31
|
else
|
31
32
|
register_task_definition(data)
|
32
33
|
end
|
33
|
-
|
34
|
+
|
35
|
+
unless @options[:mute]
|
36
|
+
puts "Equivalent aws cli command:"
|
37
|
+
file_path = "file://#{@template_definition_path.sub(/^\.\//,'')}"
|
38
|
+
puts " aws ecs register-task-definition --cli-input-json #{file_path}".colorize(:green)
|
39
|
+
puts message
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
36
43
|
def register_task_definition(data)
|
data/lib/ufo/upgrade/params.yml
CHANGED
data/lib/ufo/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
FROM ruby:2.5.0
|
@@ -0,0 +1 @@
|
|
1
|
+
FROM 123456789.dkr.ecr.us-west-2.amazonaws.com/myapp:ufo-2018-04-20T09-29-08-b7d51df
|
@@ -0,0 +1,23 @@
|
|
1
|
+
describe Ufo::Docker::Builder do
|
2
|
+
before(:all) do
|
3
|
+
create_ufo_project
|
4
|
+
end
|
5
|
+
|
6
|
+
let(:builder) { Ufo::Docker::Builder.new }
|
7
|
+
|
8
|
+
context "dockerfile uses ecr image for FROM instruction" do
|
9
|
+
it "updates the auth token before building the image" do
|
10
|
+
# builder.from_ecr_image?("spec/fixtures/dockerfiles/dockerhub/Dockerfile")
|
11
|
+
names = builder.ecr_image_names("spec/fixtures/dockerfiles/ecr/Dockerfile")
|
12
|
+
expect(names).not_to be_empty
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "dockerfile uses dockerhub image for FROM instruction" do
|
17
|
+
it "does not update the auth token before building the image" do
|
18
|
+
# builder.from_ecr_image?("spec/fixtures/dockerfiles/dockerhub/Dockerfile")
|
19
|
+
names = builder.ecr_image_names("spec/fixtures/dockerfiles/dockerhub/Dockerfile")
|
20
|
+
expect(names).to be_empty
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ufo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-cloudwatchlogs
|
@@ -393,7 +393,6 @@ files:
|
|
393
393
|
- lib/ufo/core.rb
|
394
394
|
- lib/ufo/default/settings.yml
|
395
395
|
- lib/ufo/default/templates/main.json.erb
|
396
|
-
- lib/ufo/deploy.rb
|
397
396
|
- lib/ufo/destroy.rb
|
398
397
|
- lib/ufo/docker.rb
|
399
398
|
- lib/ufo/docker/builder.rb
|
@@ -448,9 +447,12 @@ files:
|
|
448
447
|
- lib/ufo/upgrade33_to_34.rb
|
449
448
|
- lib/ufo/util.rb
|
450
449
|
- lib/ufo/version.rb
|
450
|
+
- spec/fixtures/dockerfiles/dockerhub/Dockerfile
|
451
|
+
- spec/fixtures/dockerfiles/ecr/Dockerfile
|
451
452
|
- spec/fixtures/home_existing/.aws/config
|
452
453
|
- spec/fixtures/home_existing/.docker/config.json
|
453
454
|
- spec/fixtures/settings.yml
|
455
|
+
- spec/lib/builder_spec.rb
|
454
456
|
- spec/lib/cli_spec.rb
|
455
457
|
- spec/lib/completion_spec.rb
|
456
458
|
- spec/lib/core_spec.rb
|
@@ -487,9 +489,12 @@ signing_key:
|
|
487
489
|
specification_version: 4
|
488
490
|
summary: Build Docker Containers and Ship Them to AWS ECS
|
489
491
|
test_files:
|
492
|
+
- spec/fixtures/dockerfiles/dockerhub/Dockerfile
|
493
|
+
- spec/fixtures/dockerfiles/ecr/Dockerfile
|
490
494
|
- spec/fixtures/home_existing/.aws/config
|
491
495
|
- spec/fixtures/home_existing/.docker/config.json
|
492
496
|
- spec/fixtures/settings.yml
|
497
|
+
- spec/lib/builder_spec.rb
|
493
498
|
- spec/lib/cli_spec.rb
|
494
499
|
- spec/lib/completion_spec.rb
|
495
500
|
- spec/lib/core_spec.rb
|
data/lib/ufo/deploy.rb
DELETED
File without changes
|