build-labels 0.0.13 → 0.0.15

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: 6ec498cbc10336a3948caf8d7f00c727a470313334c40d991df4bdaa242b52e2
4
- data.tar.gz: fb2e1057d222673564957cea9aac81ee29d80f2b1434af9430933ca4d19e44ca
3
+ metadata.gz: 16c94f8ee0325f5a908ff99778c8e590c93ccd270dadc7df019c86e586bc788c
4
+ data.tar.gz: 1be4edf51d1bc84e8ea74168b1d5fb1f81f83582f2bfc5d8e9d4b9f9f8dee078
5
5
  SHA512:
6
- metadata.gz: b67676c6fcbb6dca1fc79f4e7e946464a90db61b39ad2c8e262bce0d7b04ae533a38aa7cdedc39beb0d036ca92173fbd036d0db678af372429aa69ea45617dc0
7
- data.tar.gz: c840ad0c2058f3d4f2cdc964913b28aa33dd67320a348e128535c81c81c8c81217c4b3145c3fb45fd42649690c15b9a3dfc621bd55acf4b772f6b319f8d9a1b7
6
+ metadata.gz: c58fd66950b1d37f491989ae511efbaa6715f4072b630be97ca85cabd14aaf24c91b41d22d87d7c29e37445c8be472cfc59b6a378e8b45c685b9e8cf429a0a7a
7
+ data.tar.gz: 4fa922c024bfe2b1ae6169eb57633093726015bc4b195030ab8f8ed74981d5956ede6f66b6f24cf75c393628142e20decf64fcf937f6d53bc6dc084d3426ed70
@@ -6,4 +6,9 @@ services:
6
6
  build:
7
7
  context: .
8
8
  dockerfile: ./Dockerfile
9
+ service-b:
10
+ image: service-a
11
+ build: .
12
+ service-c:
13
+ image: service-a
9
14
 
@@ -68,6 +68,9 @@ module BuildLabels
68
68
  end
69
69
  end
70
70
  end
71
+ compose['services'].delete_if do |name, svc|
72
+ ! svc.key?('build')
73
+ end
71
74
  puts compose.to_yaml
72
75
  end
73
76
  end
@@ -1,18 +1,32 @@
1
1
  require_relative 'command_line'
2
2
 
3
3
  BuildLabels::CommandLine::COMMANDS[:cache] = Class.new do
4
+ def options(parser)
5
+ parser.on('', '--cache-from CACHE FROM', 'type=[local,registry] ... ')
6
+ parser.on('', '--cache-to CACHE TO', 'type=[local,registry] ...')
7
+ end
4
8
  def run(builder, params, compose_text)
5
9
  compose = YAML.load compose_text
6
- compose['services'].each do |name, service|
10
+ compose['services'].each do |service_name, service|
7
11
  next unless service['build']
8
12
 
9
13
  if service['build'].class == String
10
14
  service['build'] = { 'context' => service['build'] }
11
15
  end
16
+ # p params
12
17
  # registry = params[:registry]
13
18
  image = service['image'].gsub( /:.*/, '')
14
- service['build']['cache_from'] = [ "type=registry,ref=#{image}:cache" ]
15
- service['build']['cache_to'] = [ "type=registry,ref=#{image}:cache,mode=max" ]
19
+ if params[:'cache-from']
20
+ service['build']['cache_from'] = [ params[:'cache-from'] % {image: image, service_name: service_name} ]
21
+ else
22
+ service['build']['cache_from'] = [ "type=registry,ref=#{image}:cache" ]
23
+ end
24
+
25
+ if params[:'cache-to']
26
+ service['build']['cache_to'] = [ params[:'cache-to'] % {image: image, service_name: service_name} ]
27
+ else
28
+ service['build']['cache_to'] = [ "type=registry,ref=#{image}:cache,mode=max" ]
29
+ end
16
30
  # # - type=local,src=./.cache
17
31
  # # - type=local,dest=./.cache,mode=max
18
32
  end
@@ -46,6 +46,8 @@ module BuildLabels
46
46
  o.on('-c', '--compose COMPOSE_FILE', 'Compose file')
47
47
  o.on('-e', '--env FILE', 'Load .build_info FILE') { load_env _1 }
48
48
  o.on('-n', '--no-env', 'Do not process env variables') { true }
49
+ COMMANDS.values.select{_1.options(o) if _1.respond_to? :options }
50
+
49
51
  o.on('-h', '--help') { puts o; exit }
50
52
  rest = o.parse! args, into: params
51
53
 
@@ -12,7 +12,7 @@ BuildLabels::CommandLine::COMMANDS[:to_dockerfiles] = Class.new do
12
12
  dockerfile = svc['build'].is_a?(String) ? svc['build'] : svc['build']['context']
13
13
  dockerfile = File.join dockerfile, (svc['build']['dockerfile'] || 'Dockerfile')
14
14
  dockerfile = File.expand_path dockerfile, compose_dir
15
- raise "file ot found: #{dockerfile}" unless File.exist? dockerfile
15
+ raise "file not found: #{dockerfile}" unless File.exist? dockerfile
16
16
 
17
17
  dockerfile_lines = File.readlines(dockerfile).map(&:rstrip)
18
18
 
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module BuildLabels
2
2
  class Builder
3
- VERSION = '0.0.13'
3
+ VERSION = '0.0.15'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build-labels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom B
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-22 00:00:00.000000000 Z
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake