diff --git a/lib/kamal/configuration/builder.rb b/lib/kamal/configuration/builder.rb index 4f51669a3..0daf7e746 100644 --- a/lib/kamal/configuration/builder.rb +++ b/lib/kamal/configuration/builder.rb @@ -29,9 +29,7 @@ def arches def local_arches @local_arches ||= if remote - uname_m = `uname -m`.strip - local_arch = uname_m == "x86_64" ? "amd64" : uname_m - arches & [ local_arch ] + arches & [ Kamal::Utils.docker_arch ] else arches end diff --git a/lib/kamal/utils.rb b/lib/kamal/utils.rb index a6ba57028..46736ba54 100644 --- a/lib/kamal/utils.rb +++ b/lib/kamal/utils.rb @@ -81,4 +81,16 @@ def stable_sort!(elements, &block) def join_commands(commands) commands.map(&:strip).join(" ") end + + def docker_arch + arch = `docker info --format '{{.Architecture}}'`.strip + case arch + when /aarch64/ + "arm64" + when /x86_64/ + "amd64" + else + arch + end + end end diff --git a/test/commands/builder_test.rb b/test/commands/builder_test.rb index 759278ac4..c43c5c85c 100644 --- a/test/commands/builder_test.rb +++ b/test/commands/builder_test.rb @@ -145,10 +145,10 @@ def build_directory end def local_arch - `uname -m`.strip == "x86_64" ? "amd64" : "arm64" + Kamal::Utils.docker_arch end def remote_arch - `uname -m`.strip == "x86_64" ? "arm64" : "amd64" + Kamal::Utils.docker_arch == "arm64" ? "amd64" : "arm64" end end diff --git a/test/fixtures/deploy_with_remote_builder.yml b/test/fixtures/deploy_with_remote_builder.yml index 118142f74..6555ee6f9 100644 --- a/test/fixtures/deploy_with_remote_builder.yml +++ b/test/fixtures/deploy_with_remote_builder.yml @@ -38,5 +38,5 @@ builder: readiness_delay: 0 builder: - arch: <%= `uname -m`.strip == "x86_64" ? "arm64" : "amd64" %> + arch: <%= Kamal::Utils.docker_arch == "arm64" ? "amd64" : "arm64" %> remote: ssh://app@1.1.1.5 diff --git a/test/fixtures/deploy_with_remote_builder_and_custom_ports.yml b/test/fixtures/deploy_with_remote_builder_and_custom_ports.yml index 0f409da4a..0b39259cd 100644 --- a/test/fixtures/deploy_with_remote_builder_and_custom_ports.yml +++ b/test/fixtures/deploy_with_remote_builder_and_custom_ports.yml @@ -42,5 +42,5 @@ ssh: port: 22 builder: - arch: <%= `uname -m`.strip == "x86_64" ? "arm64" : "amd64" %> + arch: <%= Kamal::Utils.docker_arch == "arm64" ? "amd64" : "arm64" %> remote: ssh://app@1.1.1.5:2122 diff --git a/test/integration/docker/deployer/app/config/deploy.yml b/test/integration/docker/deployer/app/config/deploy.yml index de701afc2..887de8251 100644 --- a/test/integration/docker/deployer/app/config/deploy.yml +++ b/test/integration/docker/deployer/app/config/deploy.yml @@ -24,7 +24,7 @@ registry: password: root builder: driver: docker - arch: <%= uname_m = `uname -m`; uname_m == "x86_64" ? "amd64" : uname_m %> + arch: <%= Kamal::Utils.docker_arch %> args: COMMIT_SHA: <%= `git rev-parse HEAD` %> healthcheck: diff --git a/test/integration/docker/deployer/app_with_roles/config/deploy.yml b/test/integration/docker/deployer/app_with_roles/config/deploy.yml index baedfaf5b..3b9426654 100644 --- a/test/integration/docker/deployer/app_with_roles/config/deploy.yml +++ b/test/integration/docker/deployer/app_with_roles/config/deploy.yml @@ -18,7 +18,7 @@ registry: password: root builder: driver: docker - arch: <%= uname_m = `uname -m`; uname_m == "x86_64" ? "amd64" : uname_m %> + arch: <%= Kamal::Utils.docker_arch %> args: COMMIT_SHA: <%= `git rev-parse HEAD` %> healthcheck: