Load the hosts from the contexts before trying to build. If there is no context, we'll create one. If there is one but the hosts don't match we'll re-create. Where we just have a local context, there won't be any hosts but we still inspect the builder to check that it exists.
26 lines
528 B
Ruby
26 lines
528 B
Ruby
class Kamal::Commands::Builder::Native::Cached < Kamal::Commands::Builder::Native
|
|
def create
|
|
docker :buildx, :create, "--name", builder_name, "--use", "--driver=docker-container"
|
|
end
|
|
|
|
def remove
|
|
docker :buildx, :rm, builder_name
|
|
end
|
|
|
|
def push
|
|
docker :buildx, :build,
|
|
"--push",
|
|
*build_options,
|
|
build_context
|
|
end
|
|
|
|
def context_hosts
|
|
docker :buildx, :inspect, builder_name, "> /dev/null"
|
|
end
|
|
|
|
private
|
|
def builder_name
|
|
"kamal-#{config.service}-native-cached"
|
|
end
|
|
end
|