Inroduce Native::Cached builder
This commit is contained in:
@@ -7,8 +7,10 @@ class Mrsk::Commands::Builder < Mrsk::Commands::Base
|
||||
|
||||
def target
|
||||
case
|
||||
when !config.builder.multiarch?
|
||||
when !config.builder.multiarch? && !config.builder.cache?
|
||||
native
|
||||
when !config.builder.multiarch? && config.builder.cache?
|
||||
native_cached
|
||||
when config.builder.local? && config.builder.remote?
|
||||
multiarch_remote
|
||||
when config.builder.remote?
|
||||
@@ -22,6 +24,10 @@ class Mrsk::Commands::Builder < Mrsk::Commands::Base
|
||||
@native ||= Mrsk::Commands::Builder::Native.new(config)
|
||||
end
|
||||
|
||||
def native_cached
|
||||
@native ||= Mrsk::Commands::Builder::Native::Cached.new(config)
|
||||
end
|
||||
|
||||
def native_remote
|
||||
@native ||= Mrsk::Commands::Builder::Native::Remote.new(config)
|
||||
end
|
||||
|
||||
@@ -1,32 +1,17 @@
|
||||
class Mrsk::Commands::Builder::Native < Mrsk::Commands::Builder::Base
|
||||
def create
|
||||
# No-op on native without cache
|
||||
|
||||
if config.builder.cache?
|
||||
docker :buildx, :create, "--use", "--driver=docker-container"
|
||||
end
|
||||
end
|
||||
|
||||
def remove
|
||||
# No-op on native without cache
|
||||
|
||||
if config.builder.cache?
|
||||
docker :buildx, :rm, builder_name
|
||||
end
|
||||
end
|
||||
|
||||
def push
|
||||
if config.builder.cache?
|
||||
docker :buildx, :build,
|
||||
"--push",
|
||||
*build_options,
|
||||
build_context
|
||||
else
|
||||
combine \
|
||||
docker(:build, *build_options, build_context),
|
||||
docker(:push, config.absolute_image),
|
||||
docker(:push, config.latest_image)
|
||||
end
|
||||
combine \
|
||||
docker(:build, *build_options, build_context),
|
||||
docker(:push, config.absolute_image),
|
||||
docker(:push, config.latest_image)
|
||||
end
|
||||
|
||||
def info
|
||||
|
||||
16
lib/mrsk/commands/builder/native/cached.rb
Normal file
16
lib/mrsk/commands/builder/native/cached.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Mrsk::Commands::Builder::Native::Cached < Mrsk::Commands::Builder::Native
|
||||
def create
|
||||
docker :buildx, :create, "--use", "--driver=docker-container"
|
||||
end
|
||||
|
||||
def remove
|
||||
docker :buildx, :rm, builder_name
|
||||
end
|
||||
|
||||
def push
|
||||
docker :buildx, :build,
|
||||
"--push",
|
||||
*build_options,
|
||||
build_context
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user