Module: Kdep::Docker

Defined in:
lib/kdep/docker.rb

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Class Method Details

.build(tag:, context_dir:, dockerfile: nil, target: nil, platform: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kdep/docker.rb', line 7

def self.build(tag:, context_dir:, dockerfile: nil, target: nil, platform: nil)
  args = ["docker", "build", "-t", tag]
  args.push("--file", dockerfile) if dockerfile
  args.push("--target", target) if target
  args.push("--platform", platform) if platform
  args.push(context_dir)

  stdout, stderr, status = Open3.capture3(*args)
  unless status.success?
    raise Error, "docker build failed: #{stderr.strip}"
  end
  stdout
end

.push(tag) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/kdep/docker.rb', line 21

def self.push(tag)
  stdout, stderr, status = Open3.capture3("docker", "push", tag)
  unless status.success?
    raise Error, "docker push failed: #{stderr.strip}"
  end
  stdout
end