fpm-fry 0.7.1 → 0.7.2.1

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
  SHA256:
3
- metadata.gz: 15acbb0f9196652a3e2269a7e9dbfc9f3e0e215a42d7e24d03a955c17171ad5c
4
- data.tar.gz: db1351dac3ce47056b35fc257eee88480292da50efa53c96cb5a14c68df8e794
3
+ metadata.gz: 4775633d070116e35a3bdfb7bdb0359d8af49b29b08f9b68e862b5dfd6a0a91d
4
+ data.tar.gz: b6b317af4559f1deeca752e42a96c9973885e1014caa0fd5fac22d6653644617
5
5
  SHA512:
6
- metadata.gz: c73cf50dbd9e5e8105fbd37c8af6cf95655241121afa7ba0853b61b1a97e745f1d8ea1b6694dd492e9725f60b6296d443f0237b4837b9601d9bf678cdef9f442
7
- data.tar.gz: 8a3aa11180a66194d08c7f9a7a643f3136b4455c74ba14b3342e4d6255cd034ad554a14b422540352075af055785bc1f4b2e101d3bc0f61874f77e92dd035881
6
+ metadata.gz: c05ab42fc6a12903c1987313a07cdb27b7fcbd46bf3b995f20745a7da7c358b1e00ffde004eeebdcf99a4ebe05069fb6f45e9c77b7d0a2de9c19874e9f70a86d
7
+ data.tar.gz: af93127bbfc24a0bf3de4250523e86004ec49548b4517e2f55b2ddb3bb30639f669889e2ee8b83bd58a8b21d2ff314b290c60c380be3962ef69882b6752c69c0
@@ -18,6 +18,10 @@ class FPM::Fry::Client
18
18
  include FPM::Fry::WithData
19
19
  end
20
20
 
21
+ class ContainerCreationFailed < StandardError
22
+ include FPM::Fry::WithData
23
+ end
24
+
21
25
  # Raised when trying to read file that can't be read e.g. because it's a
22
26
  # directory.
23
27
  class NotAFile < StandardError
@@ -183,7 +187,28 @@ class FPM::Fry::Client
183
187
  end
184
188
 
185
189
  def pull(image)
186
- agent.post(path: url('images','create'), query: {'fromImage' => image})
190
+ last_status = ""
191
+ streamer = lambda do |chunk, remaining_bytes, total_bytes|
192
+ chunk.each_line do |line|
193
+ begin
194
+ msg = JSON.parse(line)
195
+ status, progress, id = *msg.values_at("status", "progress", "id")
196
+ id += ": " if id
197
+ status += " " if progress
198
+ move_up_one_line = $stdout.tty? && status =~ /Downloading|Extracting/ && last_status =~ /Downloading|Extracting/
199
+ last_status = status
200
+ cursor_move = move_up_one_line ? "\e[1A" : ""
201
+ puts [cursor_move, id, status, progress].join("")
202
+ rescue JSON::ParserError => e
203
+ $stderr.puts "Could not parse JSON response from docker: #{e}"
204
+ end
205
+ end
206
+ end
207
+ agent.post(path: url('images','create'), query: {'fromImage' => image}, :response_block => streamer)
208
+ end
209
+
210
+ def delete(image)
211
+ agent.delete(path: url('images',image), expects: [200, 404])
187
212
  end
188
213
 
189
214
  def create(image)
@@ -191,11 +216,19 @@ class FPM::Fry::Client
191
216
  res = agent.post(
192
217
  headers: { 'Content-Type' => 'application/json' },
193
218
  path: url,
194
- body: JSON.generate('Image' => image)
219
+ body: JSON.generate('Image' => image),
195
220
  )
196
- return JSON.parse(res.body)['Id']
221
+ data = JSON.parse(res.body)
222
+ if res.status != 201
223
+ @logger.error(data["message"])
224
+ if res.status == 404
225
+ @logger.info("execute docker pull #{image} first or specify --pull argument for fpm-fry")
226
+ end
227
+ raise ContainerCreationFailed.new("could not create container from #{image}", message: data["message"])
228
+ end
229
+ data['Id']
197
230
  rescue Excon::Error => e
198
- @logger.error("could not create image: #{image}, url: #{url}, error: #{e}")
231
+ @logger.error("could not create container from #{image}, url: #{url}, error: #{e}")
199
232
  raise
200
233
  end
201
234
 
@@ -4,8 +4,9 @@ module FPM; module Fry
4
4
 
5
5
  option '--keep', :flag, 'Keep the container after build'
6
6
  option '--overwrite', :flag, 'Overwrite package', default: true
7
- option '--verbose', :fag, 'Verbose output', default: false
7
+ option '--verbose', :flag, 'Verbose output', default: false
8
8
  option '--platform', 'PLATFORM', default: nil
9
+ option '--pull', :flag, 'Pull base image', default: false
9
10
 
10
11
  UPDATE_VALUES = ['auto','never','always']
11
12
  option '--update',"<#{UPDATE_VALUES.join('|')}>", 'Update image before installing packages ( only apt currently )', attribute_name: 'update', default: 'auto' do |value|
@@ -203,6 +204,13 @@ module FPM; module Fry
203
204
  end
204
205
  end
205
206
 
207
+ def pull_base_image!
208
+ client.pull(image)
209
+ rescue Excon::Error
210
+ logger.error "could not pull base image #{image}"
211
+ raise
212
+ end
213
+
206
214
  def build!
207
215
  body = begin
208
216
  url = client.url('containers','create')
@@ -284,7 +292,7 @@ module FPM; module Fry
284
292
  logger: logger,
285
293
  client: client,
286
294
  keep_modified_files: builder.keep_modified_files,
287
- verbose: verbose,
295
+ verbose: verbose?,
288
296
  )
289
297
  builder.recipe.apply_input(input)
290
298
  begin
@@ -407,6 +415,8 @@ module FPM; module Fry
407
415
  public
408
416
 
409
417
  def execute
418
+ pull_base_image! if pull?
419
+
410
420
  # force some eager loading
411
421
  lint_recipe_file!
412
422
  builder
@@ -140,7 +140,7 @@ module FPM; module Fry
140
140
  if options[:update]
141
141
  update = 'apt-get update && '
142
142
  end
143
- df[:dependencies] << "ENV DEBIAN_FRONTEND=noninteractive"
143
+ df[:dependencies] << "ARG DEBIAN_FRONTEND=noninteractive"
144
144
  df[:dependencies] << "RUN #{update}apt-get install --yes #{Shellwords.join(build_dependencies)}"
145
145
  when 'redhat'
146
146
  df[:dependencies] << "RUN yum -y install #{Shellwords.join(build_dependencies)}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm-fry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Lagresle
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2023-06-14 00:00:00.000000000 Z
16
+ date: 2024-02-09 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: excon
@@ -43,82 +43,6 @@ dependencies:
43
43
  - - "~>"
44
44
  - !ruby/object:Gem::Version
45
45
  version: '1.13'
46
- - !ruby/object:Gem::Dependency
47
- name: rake
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: '12.0'
53
- type: :development
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '12.0'
60
- - !ruby/object:Gem::Dependency
61
- name: rspec
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '3.0'
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 3.0.0
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '3.0'
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: 3.0.0
80
- - !ruby/object:Gem::Dependency
81
- name: webmock
82
- requirement: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - "~>"
85
- - !ruby/object:Gem::Version
86
- version: '3.0'
87
- type: :development
88
- prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - "~>"
92
- - !ruby/object:Gem::Version
93
- version: '3.0'
94
- - !ruby/object:Gem::Dependency
95
- name: coveralls
96
- requirement: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: 0.8.23
101
- type: :development
102
- prerelease: false
103
- version_requirements: !ruby/object:Gem::Requirement
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- version: 0.8.23
108
- - !ruby/object:Gem::Dependency
109
- name: simplecov
110
- requirement: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: '0'
115
- type: :development
116
- prerelease: false
117
- version_requirements: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
46
  description: deep-fried package builder
123
47
  email: dennis.konert@new-work.se
124
48
  executables:
@@ -197,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
121
  - !ruby/object:Gem::Version
198
122
  version: '0'
199
123
  requirements: []
200
- rubygems_version: 3.4.10
124
+ rubygems_version: 3.4.19
201
125
  signing_key:
202
126
  specification_version: 4
203
127
  summary: FPM Fry