Make remote builder quack as any other builder

This commit is contained in:
David Heinemeier Hansson
2023-01-13 10:16:28 +01:00
parent ea9a50ec95
commit f177ee4cfe
2 changed files with 51 additions and 56 deletions

View File

@@ -9,11 +9,12 @@ namespace :mrsk do
task :push do
run_locally do
begin
info "Building images may take a while [#{MRSK.builder.name}] (run with VERBOSE=1 for progress logging)"
debug "Using builder: #{MRSK.builder.name}"
info "Building images may take a while (run with VERBOSE=1 for progress logging)"
execute *MRSK.builder.push
rescue SSHKit::Command::Failed => e
error "Missing compatible builder, so creating a new one first"
Rake::Task["mrsk:build:create"].invoke
execute *MRSK.builder.create
execute *MRSK.builder.push
end
end unless ENV["VERSION"]
@@ -27,56 +28,16 @@ namespace :mrsk do
desc "Create a local build setup"
task :create do
run_locally do
if MRSK.builder.remote?
Rake::Task["mrsk:build:remote:create"].invoke
else
execute *MRSK.builder.create
end
debug "Using builder: #{MRSK.builder.name}"
execute *MRSK.builder.create
end
end
desc "Remove local build setup"
task :remove do
run_locally do
if MRSK.builder.remote?
Rake::Task["mrsk:build:remote:create"].invoke
else
execute *MRSK.builder.remove
end
end
end
namespace :remote do
desc "Create local and remote buildx setup for fully native multi-arch builds"
task create: %w[ create:context create:buildx ]
namespace :create do
task :context do
run_locally do
execute *MRSK.builder.create_context(local["arch"], local["host"])
execute *MRSK.builder.create_context(remote["arch"], remote["host"])
end
end
task :buildx do
run_locally do
execute *MRSK.builder.create_with_context(local["arch"])
execute *MRSK.builder.append_context(remote["arch"])
end
end
end
desc "Remove local and remote buildx setup"
task remove: %w[ remove:context mrsk:build:remove ]
namespace :remove do
task :context do
run_locally do
execute *MRSK.builder.remove_context(local["arch"])
execute *MRSK.builder.remove_context(remote["arch"])
end
end
debug "Using builder: #{MRSK.builder.name}"
execute *MRSK.builder.remove
end
end
end