Files
kamal/lib/kamal/commands/builder.rb
Donal McBreen c93f0f3048 Dump native builder
We already ensure that buildx is installed, so let's always use it.
2024-08-01 10:18:56 +01:00

60 lines
1.3 KiB
Ruby

require "active_support/core_ext/string/filters"
class Kamal::Commands::Builder < Kamal::Commands::Base
delegate :create, :remove, :push, :clean, :pull, :info, :context_hosts, :config_context_hosts, :validate_image,
:first_mirror, to: :target
include Clone
def name
target.class.to_s.remove("Kamal::Commands::Builder::").underscore.inquiry
end
def target
case
when !config.builder.multiarch? && !config.builder.cached?
local
when !config.builder.multiarch? && config.builder.cached?
local
when config.builder.local? && config.builder.remote?
multiarch_remote
when config.builder.remote?
remote
else
local
end
end
def remote
@remote ||= Kamal::Commands::Builder::Remote.new(config)
end
def local
@local ||= Kamal::Commands::Builder::Local.new(config)
end
def multiarch_remote
@multiarch_remote ||= Kamal::Commands::Builder::Multiarch::Remote.new(config)
end
def ensure_local_dependencies_installed
if name.native?
ensure_local_docker_installed
else
combine \
ensure_local_docker_installed,
ensure_local_buildx_installed
end
end
private
def ensure_local_docker_installed
docker "--version"
end
def ensure_local_buildx_installed
docker :buildx, "version"
end
end