Class: Dash::Commands::Builder::Base
Defined Under Namespace
Classes: BuilderError
Constant Summary
collapse
- ENDPOINT_DOCKER_HOST_INSPECT =
"'{{.Endpoints.docker.Host}}'"
Dash::Commands::Base::DOCKER_HEALTH_STATUS_FORMAT, Dash::Commands::Base::EXEC_PROBE_FAILED, Dash::Commands::Base::NO_HEALTHCHECK, Dash::Commands::Base::READINESS_PROGRESS_PREFIX, Dash::Commands::Base::READY_STATUSES
Instance Attribute Summary
#config
Instance Method Summary
collapse
#confirmed_empty?, #container_id_for, #ensure_docker_installed, #ensure_run_directory, #initialize, #make_directory, #make_directory_for, #read_file, #remove_directory, #remove_file, #run_over_ssh
Instance Method Details
#build_context ⇒ Object
65
66
67
|
# File 'lib/dash/commands/builder/base.rb', line 65
def build_context
config.builder.context
end
|
#build_options ⇒ Object
61
62
63
|
# File 'lib/dash/commands/builder/base.rb', line 61
def build_options
[ *build_cache, *build_labels, *build_args, *build_secrets, *build_dockerfile, *build_target, *build_ssh, *builder_provenance, *builder_sbom ]
end
|
#clean ⇒ Object
13
14
15
|
# File 'lib/dash/commands/builder/base.rb', line 13
def clean
docker :image, :rm, "--force", config.absolute_image
end
|
#clean_then_pull ⇒ Object
Dropping the old image is housekeeping - a host that never had it is not an error -
so it must not short-circuit whatever it shares a round trip with.
The || true is parenthesised because && and || bind equally and associate left:
ungrouped, an audit && clean || true && pull chain lets a FAILED audit fall into the
same || true and pull anyway, exit status 0. The group confines it to the clean.
Composed only, never executed on its own: SSHKit's command map prefixes an unknown
first word with /usr/bin/env, and the first word here is (.
26
27
28
|
# File 'lib/dash/commands/builder/base.rb', line 26
def clean_then_pull
combine [ "(", *any(clean, [ :true ]), ")" ], pull
end
|
#first_mirror ⇒ Object
78
79
80
|
# File 'lib/dash/commands/builder/base.rb', line 78
def first_mirror
docker(:info, "--format '{{index .RegistryConfig.Mirrors 0}}'")
end
|
#info ⇒ Object
51
52
53
54
55
|
# File 'lib/dash/commands/builder/base.rb', line 51
def info
combine \
docker(:context, :ls),
docker(:buildx, :ls)
end
|
#inspect_builder ⇒ Object
57
58
59
|
# File 'lib/dash/commands/builder/base.rb', line 57
def inspect_builder
docker :buildx, :inspect, builder_name unless docker_driver?
end
|
#login_to_registry_locally? ⇒ Boolean
82
83
84
|
# File 'lib/dash/commands/builder/base.rb', line 82
def login_to_registry_locally?
true
end
|
#pull ⇒ Object
47
48
49
|
# File 'lib/dash/commands/builder/base.rb', line 47
def pull
docker :pull, config.absolute_image
end
|
#push(export_action = "registry", tag_as_dirty: false, no_cache: false) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/dash/commands/builder/base.rb', line 30
def push(export_action = "registry", tag_as_dirty: false, no_cache: false)
docker :buildx, :build,
"--output=type=#{export_action}",
"--progress=plain",
*platform_options(arches),
*([ "--builder", builder_name ] unless docker_driver?),
*build_tag_options(tag_as_dirty: tag_as_dirty),
*build_options,
*([ "--no-cache" ] if no_cache),
build_context,
"2>&1"
end
|
#push_env ⇒ Object
86
87
88
|
# File 'lib/dash/commands/builder/base.rb', line 86
def push_env
{}
end
|
#validate_image ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/dash/commands/builder/base.rb', line 69
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
|