Combine multiarch and native/cache builders

Combine the two builders, as they are almost identical. The only
difference was whether the platforms were set.

The native cached builder wasn't using the context it created, so now
we do.

We'll set the driver to `docker-container` - it seems to be the default
but the Docker docs claim it is `docker`.
This commit is contained in:
Donal McBreen
2024-06-06 09:43:58 +01:00
committed by Donal McBreen
parent b7382ceeaf
commit 0ab838bc25
8 changed files with 76 additions and 82 deletions

View File

@@ -11,22 +11,17 @@ class Kamal::Commands::Builder < Kamal::Commands::Base
end
def target
if config.builder.multiarch?
if config.builder.remote?
if config.builder.local?
multiarch_remote
else
native_remote
end
else
multiarch
end
case
when !config.builder.multiarch? && !config.builder.cached?
native
when !config.builder.multiarch? && config.builder.cached?
local
when config.builder.local? && config.builder.remote?
multiarch_remote
when config.builder.remote?
native_remote
else
if config.builder.cached?
native_cached
else
native
end
local
end
end
@@ -34,16 +29,12 @@ class Kamal::Commands::Builder < Kamal::Commands::Base
@native ||= Kamal::Commands::Builder::Native.new(config)
end
def native_cached
@native ||= Kamal::Commands::Builder::Native::Cached.new(config)
end
def native_remote
@native ||= Kamal::Commands::Builder::Native::Remote.new(config)
end
def multiarch
@multiarch ||= Kamal::Commands::Builder::Multiarch.new(config)
def local
@local ||= Kamal::Commands::Builder::Local.new(config)
end
def multiarch_remote