From c93f0f30480e899918f4dde3be3965f879fecefc Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Thu, 6 Jun 2024 10:18:15 +0100 Subject: [PATCH] Dump native builder We already ensure that buildx is installed, so let's always use it. --- lib/kamal/commands/builder.rb | 6 +----- lib/kamal/commands/builder/native.rb | 20 -------------------- test/commands/builder_test.rb | 12 ++++++------ 3 files changed, 7 insertions(+), 31 deletions(-) delete mode 100644 lib/kamal/commands/builder/native.rb diff --git a/lib/kamal/commands/builder.rb b/lib/kamal/commands/builder.rb index 8f8ea7a8..f73fb5f8 100644 --- a/lib/kamal/commands/builder.rb +++ b/lib/kamal/commands/builder.rb @@ -13,7 +13,7 @@ class Kamal::Commands::Builder < Kamal::Commands::Base def target case when !config.builder.multiarch? && !config.builder.cached? - native + local when !config.builder.multiarch? && config.builder.cached? local when config.builder.local? && config.builder.remote? @@ -25,10 +25,6 @@ class Kamal::Commands::Builder < Kamal::Commands::Base end end - def native - @native ||= Kamal::Commands::Builder::Native.new(config) - end - def remote @remote ||= Kamal::Commands::Builder::Remote.new(config) end diff --git a/lib/kamal/commands/builder/native.rb b/lib/kamal/commands/builder/native.rb deleted file mode 100644 index 599bdc0f..00000000 --- a/lib/kamal/commands/builder/native.rb +++ /dev/null @@ -1,20 +0,0 @@ -class Kamal::Commands::Builder::Native < Kamal::Commands::Builder::Base - def create - # No-op on native without cache - end - - def remove - # No-op on native without cache - end - - def info - # No-op on native - end - - def push - combine \ - docker(:build, *build_options, build_context), - docker(:push, config.absolute_image), - docker(:push, config.latest_image) - end -end diff --git a/test/commands/builder_test.rb b/test/commands/builder_test.rb index 2bd1c577..17e4f4c4 100644 --- a/test/commands/builder_test.rb +++ b/test/commands/builder_test.rb @@ -15,9 +15,9 @@ class CommandsBuilderTest < ActiveSupport::TestCase test "target native when multiarch is off" do builder = new_builder_command(builder: { "multiarch" => false }) - assert_equal "native", builder.name + assert_equal "local", builder.name assert_equal \ - "docker build -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile . && docker push dhh/app:123 && docker push dhh/app:latest", + "docker buildx build --push --builder kamal-local -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile .", builder.push.join(" ") end @@ -100,7 +100,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase test "native push with build args" do builder = new_builder_command(builder: { "multiarch" => false, "args" => { "a" => 1, "b" => 2 } }) assert_equal \ - "docker build -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --build-arg a=\"1\" --build-arg b=\"2\" --file Dockerfile . && docker push dhh/app:123 && docker push dhh/app:latest", + "docker buildx build --push --builder kamal-local -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --build-arg a=\"1\" --build-arg b=\"2\" --file Dockerfile .", builder.push.join(" ") end @@ -114,7 +114,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase test "native push with build secrets" do builder = new_builder_command(builder: { "multiarch" => false, "secrets" => [ "a", "b" ] }) assert_equal \ - "docker build -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --secret id=\"a\" --secret id=\"b\" --file Dockerfile . && docker push dhh/app:123 && docker push dhh/app:latest", + "docker buildx build --push --builder kamal-local -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --secret id=\"a\" --secret id=\"b\" --file Dockerfile .", builder.push.join(" ") end @@ -140,7 +140,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase test "native context build" do builder = new_builder_command(builder: { "multiarch" => false, "context" => "./foo" }) assert_equal \ - "docker build -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ./foo && docker push dhh/app:123 && docker push dhh/app:latest", + "docker buildx build --push --builder kamal-local -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ./foo", builder.push.join(" ") end @@ -166,7 +166,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase test "native context hosts" do command = new_builder_command(builder: { "multiarch" => false }) - assert_equal :true, command.context_hosts + assert_equal "docker buildx inspect kamal-local > /dev/null", command.context_hosts.join(" ") assert_equal "", command.config_context_hosts.join(" ") end