Class: Kamal::Commands::Builder::Base

Inherits:
Kamal::Commands::Base show all
Defined in:
lib/kamal/commands/builder/base.rb

Direct Known Subclasses

Multiarch, Native

Defined Under Namespace

Classes: BuilderError

Constant Summary collapse

ENDPOINT_DOCKER_HOST_INSPECT =
"'{{.Endpoints.docker.Host}}'"

Constants inherited from Kamal::Commands::Base

Kamal::Commands::Base::DOCKER_HEALTH_STATUS_FORMAT

Instance Attribute Summary

Attributes inherited from Kamal::Commands::Base

#config

Instance Method Summary collapse

Methods inherited from Kamal::Commands::Base

#container_id_for, #initialize, #make_directory, #make_directory_for, #remove_directory, #run_over_ssh

Constructor Details

This class inherits a constructor from Kamal::Commands::Base

Instance Method Details

#build_contextObject



22
23
24
# File 'lib/kamal/commands/builder/base.rb', line 22

def build_context
  config.builder.context
end

#build_optionsObject



18
19
20
# File 'lib/kamal/commands/builder/base.rb', line 18

def build_options
  [ *build_tags, *build_cache, *build_labels, *build_args, *build_secrets, *build_dockerfile, *build_target, *build_ssh ]
end

#cleanObject



10
11
12
# File 'lib/kamal/commands/builder/base.rb', line 10

def clean
  docker :image, :rm, "--force", config.absolute_image
end

#config_context_hostsObject



39
40
41
# File 'lib/kamal/commands/builder/base.rb', line 39

def config_context_hosts
  []
end

#context_hostsObject



35
36
37
# File 'lib/kamal/commands/builder/base.rb', line 35

def context_hosts
  :true
end

#first_mirrorObject



43
44
45
# File 'lib/kamal/commands/builder/base.rb', line 43

def first_mirror
  docker(:info, "--format '{{index .RegistryConfig.Mirrors 0}}'")
end

#pullObject



14
15
16
# File 'lib/kamal/commands/builder/base.rb', line 14

def pull
  docker :pull, config.absolute_image
end

#validate_imageObject



26
27
28
29
30
31
32
33
# File 'lib/kamal/commands/builder/base.rb', line 26

def validate_image
  pipe \
    docker(:inspect, "-f", "'{{ .Config.Labels.service }}'", config.absolute_image),
    any(
      [ :grep, "-x", config.service ],
      "(echo \"Image #{config.absolute_image} is missing the 'service' label\" && exit 1)"
    )
end