Class: Jive::Docker

Inherits:
Object
  • Object
show all
Defined in:
lib/jive/docker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shell = ::Jive.shell) ⇒ Docker

Returns a new instance of Docker.



7
8
9
# File 'lib/jive/docker.rb', line 7

def initialize(shell = ::Jive.shell)
  @shell = shell
end

Instance Attribute Details

#shellObject (readonly)

Returns the value of attribute shell.



5
6
7
# File 'lib/jive/docker.rb', line 5

def shell
  @shell
end

Instance Method Details

#build(path) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/jive/docker.rb', line 11

def build(path)
  shell.execute([
    "docker",
    "build",
    "--network=host",
    "-t", image_tag_for(path),
    "."
  ], env: { "DOCKER_BUILDKIT" => "1" })
end

#launch(path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/jive/docker.rb', line 21

def launch(path)
  shell.execute([
    "docker",
    "run",
    "--network=host",
    '--entrypoint=""',
    "-it", image_tag_for(path),
    "/bin/bash -l"
  ])
end

#size(path) ⇒ Object



32
33
34
35
36
37
# File 'lib/jive/docker.rb', line 32

def size(path)
  shell.execute([
    :docker, "image", "inspect", '--format="{{.Size}}"',
    image_tag_for(path)
  ])
end