holodekk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.md +19 -0
- data/README.md +6 -0
- data/bin/holodekk-ruby +13 -0
- data/holodekk.gemspec +24 -0
- data/lib/holodekk/builder/instruction.rb +43 -0
- data/lib/holodekk/builder/option.rb +22 -0
- data/lib/holodekk/builder.rb +33 -0
- data/lib/holodekk/docker/dockerfile/instruction_builder/flag.rb +37 -0
- data/lib/holodekk/docker/dockerfile/instruction_builder/key_pair.rb +22 -0
- data/lib/holodekk/docker/dockerfile/instruction_builder/option.rb +22 -0
- data/lib/holodekk/docker/dockerfile/instruction_builder/quoted_string.rb +21 -0
- data/lib/holodekk/docker/dockerfile/instruction_builder/raw_value.rb +21 -0
- data/lib/holodekk/docker/dockerfile/instruction_builder/value_array.rb +21 -0
- data/lib/holodekk/docker/dockerfile/instruction_builder/value_list.rb +21 -0
- data/lib/holodekk/docker/dockerfile/instruction_builder.rb +71 -0
- data/lib/holodekk/docker/dockerfile.rb +3 -0
- data/lib/holodekk/docker.rb +3 -0
- data/lib/holodekk/image/instructions/add.rb +45 -0
- data/lib/holodekk/image/instructions/arg.rb +27 -0
- data/lib/holodekk/image/instructions/cmd.rb +27 -0
- data/lib/holodekk/image/instructions/copy.rb +42 -0
- data/lib/holodekk/image/instructions/entrypoint.rb +11 -0
- data/lib/holodekk/image/instructions/env.rb +25 -0
- data/lib/holodekk/image/instructions/expose.rb +24 -0
- data/lib/holodekk/image/instructions/from.rb +30 -0
- data/lib/holodekk/image/instructions/healthcheck.rb +27 -0
- data/lib/holodekk/image/instructions/label.rb +31 -0
- data/lib/holodekk/image/instructions/onbuild.rb +23 -0
- data/lib/holodekk/image/instructions/run/options/with_bind_mount.rb +31 -0
- data/lib/holodekk/image/instructions/run/options/with_cache_mount.rb +40 -0
- data/lib/holodekk/image/instructions/run/options/with_secret_mount.rb +59 -0
- data/lib/holodekk/image/instructions/run/options/with_ssh_mount.rb +17 -0
- data/lib/holodekk/image/instructions/run/options/with_tmpfs_mount.rb +17 -0
- data/lib/holodekk/image/instructions/run.rb +69 -0
- data/lib/holodekk/image/instructions/shell.rb +23 -0
- data/lib/holodekk/image/instructions/stopsignal.rb +23 -0
- data/lib/holodekk/image/instructions/user.rb +26 -0
- data/lib/holodekk/image/instructions/volume.rb +27 -0
- data/lib/holodekk/image/instructions/workdir.rb +23 -0
- data/lib/holodekk/image.rb +66 -0
- data/lib/holodekk/version.rb +5 -0
- data/lib/holodekk.rb +14 -0
- metadata +114 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d3a5914a607604f7d009d25096a445f157fc5f387e292a52ca660482e491104b
|
|
4
|
+
data.tar.gz: 8041f27c22120bd272aff93c6773584958d22d66d3b65d62d7f3f9d239140e05
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7d96652bde4be22c0d86e479e5bcd0975fcfa3760cc30a2aa6ca32011cb9ca712b4c5bb3e5974dd8cdf2a779cb3b2576f0df6493e1029df948a490438f340d0e
|
|
7
|
+
data.tar.gz: 365afddd2f53cdc1f8d4e2f02ccd79c4ba42fb9b6935ea59ae248f35f6ea448f3150c60cef0ec6a1d59f16843d1a82b2a9c76bd1e9a64dda0ff688d169f8a997
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2023 Josh Williams <jdubz@holodekk.io>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Holodekk
|
|
2
|
+
====
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
data/bin/holodekk-ruby
ADDED
data/holodekk.gemspec
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/holodekk/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'holodekk'
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
s.version = Holodekk::VERSION
|
|
9
|
+
s.description = 'Ruby interfaces for the Holodekk platform.'
|
|
10
|
+
s.summary = s.description
|
|
11
|
+
s.authors = ['Josh Williams']
|
|
12
|
+
s.email = 'jdubz@holodekk.io'
|
|
13
|
+
s.files = %w[holodekk.gemspec] + Dir['*.md', 'bin/*', 'lib/**/*.rb']
|
|
14
|
+
s.homepage = 'https://holodekk.io'
|
|
15
|
+
s.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
s.required_ruby_version = '>= 2.6.0'
|
|
18
|
+
|
|
19
|
+
s.executables << 'holodekk-ruby'
|
|
20
|
+
|
|
21
|
+
s.add_runtime_dependency('activemodel', '~> 6.0')
|
|
22
|
+
s.add_runtime_dependency('activesupport', '~> 6.0')
|
|
23
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
|
24
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Builder
|
|
5
|
+
class Instruction
|
|
6
|
+
include ActiveModel::Model
|
|
7
|
+
include ActiveModel::Validations
|
|
8
|
+
|
|
9
|
+
class << self
|
|
10
|
+
def build
|
|
11
|
+
raise NotImplementedError
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def instruction_tag(tag)
|
|
15
|
+
@tag = tag
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def tag
|
|
19
|
+
@tag ||= name.demodulize.upcase
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def tag
|
|
24
|
+
self.class.tag
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def as_json(options = {})
|
|
28
|
+
raise NotImplementedError
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def to_json(*args)
|
|
32
|
+
as_json.to_json(*args)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
protected
|
|
36
|
+
|
|
37
|
+
def add_option(builder, key)
|
|
38
|
+
val = send key
|
|
39
|
+
builder.option(key, val) unless val.nil?
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Builder
|
|
5
|
+
class Option
|
|
6
|
+
include ActiveModel::Model
|
|
7
|
+
include ActiveModel::Validations
|
|
8
|
+
|
|
9
|
+
def as_dockerfile(options = {})
|
|
10
|
+
raise NotImplementedError
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def as_json(options = {})
|
|
14
|
+
raise NotImplementedError
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def to_json(*args)
|
|
18
|
+
as_json.to_json(*args)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'builder/instruction'
|
|
4
|
+
require_relative 'builder/option'
|
|
5
|
+
|
|
6
|
+
module Holodekk
|
|
7
|
+
class Builder
|
|
8
|
+
class << self
|
|
9
|
+
def instruction(klass)
|
|
10
|
+
method_name = klass.name.split('::').last.underscore
|
|
11
|
+
define_method method_name do |*args, **kwargs, &block|
|
|
12
|
+
ins = klass.build(*args, **kwargs, &block)
|
|
13
|
+
@instructions << ins
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def option(klass)
|
|
18
|
+
method_name = klass.name.split('::').last.underscore
|
|
19
|
+
define_method method_name do |*args, **kwargs, &block|
|
|
20
|
+
raise "option #{method_name} invoked, but no options target supplied to builder." if @options.nil?
|
|
21
|
+
|
|
22
|
+
opt = klass.build(*args, **kwargs, &block)
|
|
23
|
+
@options << opt
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def initialize(instructions, options = nil)
|
|
29
|
+
@instructions = instructions
|
|
30
|
+
@options = options
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
module Docker
|
|
5
|
+
module Dockerfile
|
|
6
|
+
class InstructionBuilder
|
|
7
|
+
class Flag
|
|
8
|
+
attr_accessor :name, :value, :display_state
|
|
9
|
+
|
|
10
|
+
alias display_state? display_state
|
|
11
|
+
|
|
12
|
+
def initialize(name = '', value = '', display_state: false)
|
|
13
|
+
@name = name
|
|
14
|
+
@value = value
|
|
15
|
+
@display_state = display_state
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def enabled?
|
|
19
|
+
value ? true : false
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def output
|
|
23
|
+
return "--#{name}=#{enabled?}" if display_state.eql?(:always)
|
|
24
|
+
|
|
25
|
+
if enabled?
|
|
26
|
+
return "--#{name}=#{enabled?}" if display_state?
|
|
27
|
+
|
|
28
|
+
return "--#{name}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
''
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
module Docker
|
|
5
|
+
module Dockerfile
|
|
6
|
+
class InstructionBuilder
|
|
7
|
+
class KeyPair
|
|
8
|
+
attr_accessor :key, :value
|
|
9
|
+
|
|
10
|
+
def initialize(key = '', value = '')
|
|
11
|
+
@key = key.is_a?(String) ? RawValue.new(key) : key
|
|
12
|
+
@value = value.is_a?(String) ? RawValue.new(value) : value
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def output
|
|
16
|
+
"#{key.output}=#{value.output}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
module Docker
|
|
5
|
+
module Dockerfile
|
|
6
|
+
class InstructionBuilder
|
|
7
|
+
class Option
|
|
8
|
+
attr_accessor :key, :value
|
|
9
|
+
|
|
10
|
+
def initialize(key = '', value = '')
|
|
11
|
+
@key = key
|
|
12
|
+
@value = value
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def output
|
|
16
|
+
"--#{key}=#{value}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
module Docker
|
|
5
|
+
module Dockerfile
|
|
6
|
+
class InstructionBuilder
|
|
7
|
+
class QuotedString
|
|
8
|
+
attr_accessor :value
|
|
9
|
+
|
|
10
|
+
def initialize(value = '')
|
|
11
|
+
@value = value
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def output
|
|
15
|
+
"\"#{value}\""
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
module Docker
|
|
5
|
+
module Dockerfile
|
|
6
|
+
class InstructionBuilder
|
|
7
|
+
class RawValue
|
|
8
|
+
attr_accessor :value
|
|
9
|
+
|
|
10
|
+
def initialize(value = '')
|
|
11
|
+
@value = value
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def output
|
|
15
|
+
value.to_s
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
module Docker
|
|
5
|
+
module Dockerfile
|
|
6
|
+
class InstructionBuilder
|
|
7
|
+
class ValueArray
|
|
8
|
+
attr_accessor :values
|
|
9
|
+
|
|
10
|
+
def initialize(*values)
|
|
11
|
+
@values = values
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def output
|
|
15
|
+
"[#{values.map(&:output).join(', ')}]"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
module Docker
|
|
5
|
+
module Dockerfile
|
|
6
|
+
class InstructionBuilder
|
|
7
|
+
class ValueList
|
|
8
|
+
attr_accessor :values
|
|
9
|
+
|
|
10
|
+
def initialize(*values)
|
|
11
|
+
@values = values
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def output
|
|
15
|
+
values.map(&:output).join(' ').to_s
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'instruction_builder/flag'
|
|
4
|
+
require_relative 'instruction_builder/key_pair'
|
|
5
|
+
require_relative 'instruction_builder/option'
|
|
6
|
+
require_relative 'instruction_builder/quoted_string'
|
|
7
|
+
require_relative 'instruction_builder/raw_value'
|
|
8
|
+
require_relative 'instruction_builder/value_array'
|
|
9
|
+
require_relative 'instruction_builder/value_list'
|
|
10
|
+
|
|
11
|
+
module Holodekk
|
|
12
|
+
module Docker
|
|
13
|
+
module Dockerfile
|
|
14
|
+
class InstructionBuilder
|
|
15
|
+
attr_accessor :tag
|
|
16
|
+
|
|
17
|
+
def initialize(instruction = nil)
|
|
18
|
+
@tag = instruction.present? ? instruction.class.tag : 'UNKNOWN'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def flag(name, enabled, **kwargs)
|
|
22
|
+
elements << Flag.new(name, enabled, **kwargs)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def key_pair(key, value, **kwargs)
|
|
26
|
+
elements << KeyPair.new(key, value, **kwargs)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def option(key, value)
|
|
30
|
+
elements << Option.new(key, value)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def quoted_string(value)
|
|
34
|
+
elements << QuotedString.new(value)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def raw_value(value)
|
|
38
|
+
elements << RawValue.new(value)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def value_array(*values)
|
|
42
|
+
elements << ValueArray.new(*values)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def value_list(*values)
|
|
46
|
+
elements << ValueList.new(*values)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def elements
|
|
50
|
+
@elements ||= []
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def output
|
|
54
|
+
chunks = []
|
|
55
|
+
chunks << tag
|
|
56
|
+
elements.each do |e|
|
|
57
|
+
o = e.output
|
|
58
|
+
chunks << o unless o.blank?
|
|
59
|
+
end
|
|
60
|
+
chunks.join(' ')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def output!
|
|
64
|
+
res = output
|
|
65
|
+
elements.clear
|
|
66
|
+
res
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Image
|
|
5
|
+
module Instructions
|
|
6
|
+
class Add < Holodekk::Builder::Instruction
|
|
7
|
+
attr_accessor :sources, :target, :chown, :checksum, :keep_git_dir, :link
|
|
8
|
+
|
|
9
|
+
alias keep_git_dir? keep_git_dir
|
|
10
|
+
alias link? link
|
|
11
|
+
|
|
12
|
+
validates_presence_of :sources, :target
|
|
13
|
+
validate :validate_sources
|
|
14
|
+
validates :chown, format: { with: Holodekk::CHOWN_RE }, allow_blank: true
|
|
15
|
+
validates :keep_git_dir, inclusion: { in: [true, false] }, allow_blank: true
|
|
16
|
+
validates :link, inclusion: { in: [true, false] }, allow_blank: true
|
|
17
|
+
|
|
18
|
+
def self.build(sources, target, **kwargs)
|
|
19
|
+
s = *sources
|
|
20
|
+
new({ sources: s, target: target }.merge(kwargs))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def to_dockerfile
|
|
24
|
+
builder = Docker::Dockerfile::InstructionBuilder.new(self)
|
|
25
|
+
builder.flag('link', link)
|
|
26
|
+
builder.flag('keep-git-dir', keep_git_dir, display_state: true)
|
|
27
|
+
add_option(builder, 'chown')
|
|
28
|
+
add_option(builder, 'checksum')
|
|
29
|
+
builder.value_list(*sources.map do |s|
|
|
30
|
+
Docker::Dockerfile::InstructionBuilder::QuotedString.new(s)
|
|
31
|
+
end)
|
|
32
|
+
builder.quoted_string(target)
|
|
33
|
+
builder.output
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
protected
|
|
37
|
+
|
|
38
|
+
def validate_sources
|
|
39
|
+
invalid_sources = sources.select(&:empty?)
|
|
40
|
+
errors.add(:sources, 'invalid source') unless invalid_sources.empty?
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Image
|
|
5
|
+
module Instructions
|
|
6
|
+
class Arg < Holodekk::Builder::Instruction
|
|
7
|
+
attr_accessor :arg, :default
|
|
8
|
+
|
|
9
|
+
validates_presence_of :arg
|
|
10
|
+
|
|
11
|
+
def self.build(arg, **kwargs)
|
|
12
|
+
new({ arg: arg }.merge(kwargs))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_dockerfile
|
|
16
|
+
builder = Docker::Dockerfile::InstructionBuilder.new(self)
|
|
17
|
+
if default.nil?
|
|
18
|
+
builder.raw_value(arg)
|
|
19
|
+
else
|
|
20
|
+
builder.key_pair(arg, default)
|
|
21
|
+
end
|
|
22
|
+
builder.output
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Image
|
|
5
|
+
module Instructions
|
|
6
|
+
class Cmd < Holodekk::Builder::Instruction
|
|
7
|
+
attr_accessor :cmd
|
|
8
|
+
|
|
9
|
+
validates_presence_of :cmd
|
|
10
|
+
|
|
11
|
+
def self.build(cmd)
|
|
12
|
+
new(cmd: cmd)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_dockerfile
|
|
16
|
+
builder = Docker::Dockerfile::InstructionBuilder.new(self)
|
|
17
|
+
if cmd.is_a?(Array)
|
|
18
|
+
builder.value_array(*cmd.map { |c| Docker::Dockerfile::InstructionBuilder::QuotedString.new(c) })
|
|
19
|
+
else
|
|
20
|
+
builder.raw_value(cmd)
|
|
21
|
+
end
|
|
22
|
+
builder.output
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Image
|
|
5
|
+
module Instructions
|
|
6
|
+
class Copy < Holodekk::Builder::Instruction
|
|
7
|
+
attr_accessor :sources, :target, :chown, :link, :from
|
|
8
|
+
|
|
9
|
+
alias link? link
|
|
10
|
+
|
|
11
|
+
validates_presence_of :sources, :target
|
|
12
|
+
validate :validate_sources
|
|
13
|
+
validates :chown, format: { with: Holodekk::CHOWN_RE }, allow_blank: true
|
|
14
|
+
validates :link, inclusion: { in: [true, false] }, allow_blank: true
|
|
15
|
+
|
|
16
|
+
def self.build(sources, target, **kwargs)
|
|
17
|
+
s = *sources
|
|
18
|
+
new({ sources: s, target: target }.merge(kwargs))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_dockerfile
|
|
22
|
+
builder = Docker::Dockerfile::InstructionBuilder.new(self)
|
|
23
|
+
builder.flag('link', link)
|
|
24
|
+
add_option(builder, 'chown')
|
|
25
|
+
add_option(builder, 'from')
|
|
26
|
+
builder.value_list(*sources.map do |s|
|
|
27
|
+
Docker::Dockerfile::InstructionBuilder::QuotedString.new(s)
|
|
28
|
+
end)
|
|
29
|
+
builder.quoted_string(target)
|
|
30
|
+
builder.output
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
protected
|
|
34
|
+
|
|
35
|
+
def validate_sources
|
|
36
|
+
invalid_sources = sources.select(&:empty?)
|
|
37
|
+
errors.add(:sources, 'invalid source') unless invalid_sources.empty?
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Image
|
|
5
|
+
module Instructions
|
|
6
|
+
class Env < Holodekk::Builder::Instruction
|
|
7
|
+
attr_accessor :env
|
|
8
|
+
|
|
9
|
+
validates_presence_of :env
|
|
10
|
+
|
|
11
|
+
def self.build(env)
|
|
12
|
+
new({ env: env })
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_dockerfile
|
|
16
|
+
builder = Docker::Dockerfile::InstructionBuilder.new(self)
|
|
17
|
+
env.each_pair do |key, value|
|
|
18
|
+
builder.key_pair(key, Docker::Dockerfile::InstructionBuilder::QuotedString.new(value))
|
|
19
|
+
end
|
|
20
|
+
builder.output
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Image
|
|
5
|
+
module Instructions
|
|
6
|
+
class Expose < Holodekk::Builder::Instruction
|
|
7
|
+
attr_accessor :ports
|
|
8
|
+
|
|
9
|
+
validates_presence_of :ports
|
|
10
|
+
|
|
11
|
+
def self.build(ports)
|
|
12
|
+
p = *ports
|
|
13
|
+
new({ ports: p })
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_dockerfile
|
|
17
|
+
builder = Docker::Dockerfile::InstructionBuilder.new(self)
|
|
18
|
+
builder.value_list(*ports.map { |p| Docker::Dockerfile::InstructionBuilder::RawValue.new(p) })
|
|
19
|
+
builder.output
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Holodekk
|
|
4
|
+
class Image
|
|
5
|
+
module Instructions
|
|
6
|
+
class From < Holodekk::Builder::Instruction
|
|
7
|
+
attr_accessor :image
|
|
8
|
+
|
|
9
|
+
validates :image, presence: true
|
|
10
|
+
|
|
11
|
+
def self.build(image)
|
|
12
|
+
new({ image: image })
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_dockerfile(_options = {})
|
|
16
|
+
builder = Docker::Dockerfile::InstructionBuilder.new(self)
|
|
17
|
+
builder.raw_value(image)
|
|
18
|
+
builder.output
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def as_json(_options = {})
|
|
22
|
+
{
|
|
23
|
+
type: 'From',
|
|
24
|
+
image: image
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|