Move native remote to just remote
It's just a remote builder, that will build whichever platform is asked for, so let's remove the "native" part. We'll also remove the service name from the builder name, so multiple services can share the same builder.
This commit is contained in:
@@ -19,7 +19,7 @@ class Kamal::Commands::Builder < Kamal::Commands::Base
|
||||
when config.builder.local? && config.builder.remote?
|
||||
multiarch_remote
|
||||
when config.builder.remote?
|
||||
native_remote
|
||||
remote
|
||||
else
|
||||
local
|
||||
end
|
||||
@@ -29,8 +29,8 @@ class Kamal::Commands::Builder < Kamal::Commands::Base
|
||||
@native ||= Kamal::Commands::Builder::Native.new(config)
|
||||
end
|
||||
|
||||
def native_remote
|
||||
@native ||= Kamal::Commands::Builder::Native::Remote.new(config)
|
||||
def remote
|
||||
@remote ||= Kamal::Commands::Builder::Remote.new(config)
|
||||
end
|
||||
|
||||
def local
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Kamal::Commands::Builder::Native::Remote < Kamal::Commands::Builder::Native
|
||||
class Kamal::Commands::Builder::Remote < Kamal::Commands::Builder::Base
|
||||
def create
|
||||
chain \
|
||||
create_context,
|
||||
@@ -27,7 +27,7 @@ class Kamal::Commands::Builder::Native::Remote < Kamal::Commands::Builder::Nativ
|
||||
end
|
||||
|
||||
def context_hosts
|
||||
context_host(builder_name_with_arch)
|
||||
context_host(builder_name)
|
||||
end
|
||||
|
||||
def config_context_hosts
|
||||
@@ -37,11 +37,7 @@ class Kamal::Commands::Builder::Native::Remote < Kamal::Commands::Builder::Nativ
|
||||
|
||||
private
|
||||
def builder_name
|
||||
"kamal-#{config.service}-native-remote"
|
||||
end
|
||||
|
||||
def builder_name_with_arch
|
||||
"#{builder_name}-#{remote_arch}"
|
||||
"kamal-remote-#{remote_arch}"
|
||||
end
|
||||
|
||||
def platform
|
||||
@@ -49,16 +45,15 @@ class Kamal::Commands::Builder::Native::Remote < Kamal::Commands::Builder::Nativ
|
||||
end
|
||||
|
||||
def create_context
|
||||
docker :context, :create,
|
||||
builder_name_with_arch, "--description", "'#{builder_name} #{remote_arch} native host'", "--docker", "'host=#{remote_host}'"
|
||||
docker :context, :create, builder_name, "--description", "'#{builder_name} host'", "--docker", "'host=#{remote_host}'"
|
||||
end
|
||||
|
||||
def remove_context
|
||||
docker :context, :rm, builder_name_with_arch
|
||||
docker :context, :rm, builder_name
|
||||
end
|
||||
|
||||
def create_buildx
|
||||
docker :buildx, :create, "--name", builder_name, builder_name_with_arch, "--platform", platform
|
||||
docker :buildx, :create, "--name", builder_name, builder_name, "--platform", platform
|
||||
end
|
||||
|
||||
def remove_buildx
|
||||
@@ -213,16 +213,16 @@ class CliBuildTest < CliTestCase
|
||||
test "create remote" do
|
||||
run_command("create", fixture: :with_remote_builder).tap do |output|
|
||||
assert_match "Running /usr/bin/env true on 1.1.1.5", output
|
||||
assert_match "docker context create kamal-app-native-remote-amd64 --description 'kamal-app-native-remote amd64 native host' --docker 'host=ssh://app@1.1.1.5'", output
|
||||
assert_match "docker buildx create --name kamal-app-native-remote kamal-app-native-remote-amd64 --platform linux/amd64", output
|
||||
assert_match "docker context create kamal-remote-amd64 --description 'kamal-remote-amd64 host' --docker 'host=ssh://app@1.1.1.5'", output
|
||||
assert_match "docker buildx create --name kamal-remote-amd64 kamal-remote-amd64 --platform linux/amd64", output
|
||||
end
|
||||
end
|
||||
|
||||
test "create remote with custom ports" do
|
||||
run_command("create", fixture: :with_remote_builder_and_custom_ports).tap do |output|
|
||||
assert_match "Running /usr/bin/env true on 1.1.1.5", output
|
||||
assert_match "docker context create kamal-app-native-remote-amd64 --description 'kamal-app-native-remote amd64 native host' --docker 'host=ssh://app@1.1.1.5:2122'", output
|
||||
assert_match "docker buildx create --name kamal-app-native-remote kamal-app-native-remote-amd64 --platform linux/amd64", output
|
||||
assert_match "docker context create kamal-remote-amd64 --description 'kamal-remote-amd64 host' --docker 'host=ssh://app@1.1.1.5:2122'", output
|
||||
assert_match "docker buildx create --name kamal-remote-amd64 kamal-remote-amd64 --platform linux/amd64", output
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ class CommandsBuilderTest < ActiveSupport::TestCase
|
||||
|
||||
test "target native remote when only remote is set" do
|
||||
builder = new_builder_command(builder: { "remote" => { "arch" => "amd64" }, "cache" => { "type" => "gha" } })
|
||||
assert_equal "native/remote", builder.name
|
||||
assert_equal "remote", builder.name
|
||||
assert_equal \
|
||||
"docker buildx build --push --platform linux/amd64 --builder kamal-app-native-remote -t dhh/app:123 -t dhh/app:latest --cache-to type=gha --cache-from type=gha --label service=\"app\" --file Dockerfile .",
|
||||
"docker buildx build --push --platform linux/amd64 --builder kamal-remote-amd64 -t dhh/app:123 -t dhh/app:latest --cache-to type=gha --cache-from type=gha --label service=\"app\" --file Dockerfile .",
|
||||
builder.push.join(" ")
|
||||
end
|
||||
|
||||
@@ -154,7 +154,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase
|
||||
test "remote context build" do
|
||||
builder = new_builder_command(builder: { "remote" => { "arch" => "amd64" }, "context" => "./foo" })
|
||||
assert_equal \
|
||||
"docker buildx build --push --platform linux/amd64 --builder kamal-app-native-remote -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ./foo",
|
||||
"docker buildx build --push --platform linux/amd64 --builder kamal-remote-amd64 -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ./foo",
|
||||
builder.push.join(" ")
|
||||
end
|
||||
|
||||
@@ -178,7 +178,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase
|
||||
|
||||
test "native remote context hosts" do
|
||||
command = new_builder_command(builder: { "remote" => { "arch" => "amd64", "host" => "ssh://host" } })
|
||||
assert_equal "docker context inspect kamal-app-native-remote-amd64 --format '{{.Endpoints.docker.Host}}'", command.context_hosts.join(" ")
|
||||
assert_equal "docker context inspect kamal-remote-amd64 --format '{{.Endpoints.docker.Host}}'", command.context_hosts.join(" ")
|
||||
assert_equal [ "ssh://host" ], command.config_context_hosts
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user