diff --git a/lib/kamal/cli/templates/deploy.yml b/lib/kamal/cli/templates/deploy.yml index 2602c66d8..119961b9d 100644 --- a/lib/kamal/cli/templates/deploy.yml +++ b/lib/kamal/cli/templates/deploy.yml @@ -18,6 +18,10 @@ registry: password: - KAMAL_REGISTRY_PASSWORD +# Configure builder setup. +builder: + arch: amd64 + # Inject ENV variables into containers (secrets come from .env). # Remember to run `kamal env push` after making changes! # env: @@ -30,16 +34,6 @@ registry: # ssh: # user: app -# Configure builder setup. -# builder: -# args: -# RUBY_VERSION: 3.2.0 -# secrets: -# - GITHUB_TOKEN -# remote: -# arch: amd64 -# host: ssh://app@192.168.0.1 - # Use accessory services (secrets come from .env). # accessories: # db: diff --git a/lib/kamal/configuration/validator/builder.rb b/lib/kamal/configuration/validator/builder.rb index ebccdf817..4bd815bfd 100644 --- a/lib/kamal/configuration/validator/builder.rb +++ b/lib/kamal/configuration/validator/builder.rb @@ -5,5 +5,7 @@ def validate! if config["cache"] && config["cache"]["type"] error "Invalid cache type: #{config["cache"]["type"]}" unless [ "gha", "registry" ].include?(config["cache"]["type"]) end + + error "Builder arch not set" unless config["arch"].present? end end diff --git a/test/cli/build_test.rb b/test/cli/build_test.rb index c8f01540a..11b6fb1eb 100644 --- a/test/cli/build_test.rb +++ b/test/cli/build_test.rb @@ -26,7 +26,7 @@ class CliBuildTest < CliTestCase assert_match /Cloning repo into build directory/, output assert_match /git -C #{Dir.tmpdir}\/kamal-clones\/app-#{pwd_sha} clone #{Dir.pwd}/, output assert_match /docker --version && docker buildx version/, output - assert_match /docker build --push --platform linux\/amd64,linux\/arm64 --builder kamal-local-docker-container -t dhh\/app:999 -t dhh\/app:latest --label service="app" --file Dockerfile \. as .*@localhost/, output + assert_match /docker build --push --platform linux\/amd64 --builder kamal-local-docker-container -t dhh\/app:999 -t dhh\/app:latest --label service="app" --file Dockerfile \. as .*@localhost/, output end end end @@ -49,7 +49,7 @@ class CliBuildTest < CliTestCase SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:git, "-C", build_directory, :submodule, :update, "--init") SSHKit::Backend::Abstract.any_instance.expects(:execute) - .with(:docker, :build, "--push", "--platform", "linux/amd64,linux/arm64", "--builder", "kamal-local-docker-container", "-t", "dhh/app:999", "-t", "dhh/app:latest", "--label", "service=\"app\"", "--file", "Dockerfile", ".") + .with(:docker, :build, "--push", "--platform", "linux/amd64", "--builder", "kamal-local-docker-container", "-t", "dhh/app:999", "-t", "dhh/app:latest", "--label", "service=\"app\"", "--file", "Dockerfile", ".") SSHKit::Backend::Abstract.any_instance.expects(:capture_with_info) .with(:git, "-C", anything, :"rev-parse", :HEAD) @@ -74,7 +74,7 @@ class CliBuildTest < CliTestCase assert_no_match /Cloning repo into build directory/, output assert_hook_ran "pre-build", output, **hook_variables assert_match /docker --version && docker buildx version/, output - assert_match /docker build --push --platform linux\/amd64,linux\/arm64 --builder kamal-local-docker-container -t dhh\/app:999 -t dhh\/app:latest --label service="app" --file Dockerfile . as .*@localhost/, output + assert_match /docker build --push --platform linux\/amd64 --builder kamal-local-docker-container -t dhh\/app:999 -t dhh\/app:latest --label service="app" --file Dockerfile . as .*@localhost/, output end end @@ -137,7 +137,7 @@ class CliBuildTest < CliTestCase .returns("") SSHKit::Backend::Abstract.any_instance.expects(:execute) - .with(:docker, :build, "--push", "--platform", "linux/amd64,linux/arm64", "--builder", "kamal-local-docker-container", "-t", "dhh/app:999", "-t", "dhh/app:latest", "--label", "service=\"app\"", "--file", "Dockerfile", ".") + .with(:docker, :build, "--push", "--platform", "linux/amd64", "--builder", "kamal-local-docker-container", "-t", "dhh/app:999", "-t", "dhh/app:latest", "--label", "service=\"app\"", "--file", "Dockerfile", ".") run_command("push").tap do |output| assert_match /WARN Missing compatible builder, so creating a new one first/, output diff --git a/test/commands/accessory_test.rb b/test/commands/accessory_test.rb index 94c1bebcb..400029884 100644 --- a/test/commands/accessory_test.rb +++ b/test/commands/accessory_test.rb @@ -5,6 +5,7 @@ class CommandsAccessoryTest < ActiveSupport::TestCase @config = { service: "app", image: "dhh/app", registry: { "server" => "private.registry", "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], + builder: { "arch" => "amd64" }, accessories: { "mysql" => { "image" => "private.registry/mysql:8.0", diff --git a/test/commands/app_test.rb b/test/commands/app_test.rb index 502501cd7..bee7dc34b 100644 --- a/test/commands/app_test.rb +++ b/test/commands/app_test.rb @@ -5,7 +5,7 @@ class CommandsAppTest < ActiveSupport::TestCase ENV["RAILS_MASTER_KEY"] = "456" Kamal::Configuration.any_instance.stubs(:run_id).returns("12345678901234567890123456789012") - @config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], env: { "secret" => [ "RAILS_MASTER_KEY" ] } } + @config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], env: { "secret" => [ "RAILS_MASTER_KEY" ] }, builder: { "arch" => "amd64" } } end teardown do diff --git a/test/commands/auditor_test.rb b/test/commands/auditor_test.rb index 5b7a34c55..2aaafd677 100644 --- a/test/commands/auditor_test.rb +++ b/test/commands/auditor_test.rb @@ -8,7 +8,7 @@ class CommandsAuditorTest < ActiveSupport::TestCase freeze_time @config = { - service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ] + service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, builder: { "arch" => "amd64" }, servers: [ "1.1.1.1" ] } @auditor = new_command diff --git a/test/commands/builder_test.rb b/test/commands/builder_test.rb index 960c17fe5..b70941268 100644 --- a/test/commands/builder_test.rb +++ b/test/commands/builder_test.rb @@ -2,14 +2,14 @@ class CommandsBuilderTest < ActiveSupport::TestCase setup do - @config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ] } + @config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], builder: { "arch" => "amd64" } } end - test "target linux/amd64,linux/arm64 locally by default" do + test "target linux/amd64 locally by default" do builder = new_builder_command(builder: { "cache" => { "type" => "gha" } }) assert_equal "local", builder.name assert_equal \ - "docker build --push --platform linux/amd64,linux/arm64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --cache-to type=gha --cache-from type=gha --label service=\"app\" --file Dockerfile .", + "docker build --push --platform linux/amd64 --builder kamal-local-docker-container -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 @@ -25,12 +25,12 @@ class CommandsBuilderTest < ActiveSupport::TestCase builder = new_builder_command(builder: { "cache" => { "type" => "gha" } }) assert_equal "local", builder.name assert_equal \ - "docker build --push --platform linux/amd64,linux/arm64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --cache-to type=gha --cache-from type=gha --label service=\"app\" --file Dockerfile .", + "docker build --push --platform linux/amd64 --builder kamal-local-docker-container -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 - test "hybrid build if remote is set" do - builder = new_builder_command(builder: { "remote" => "ssh://app@127.0.0.1", "cache" => { "type" => "gha" } }) + test "hybrid build if remote is set and building multiarch" do + builder = new_builder_command(builder: { "arch" => [ "amd64", "arm64" ], "remote" => "ssh://app@127.0.0.1", "cache" => { "type" => "gha" } }) assert_equal "hybrid", builder.name assert_equal \ "docker build --push --platform linux/amd64,linux/arm64 --builder kamal-hybrid-docker-container-ssh---app-127-0-0-1 -t dhh/app:123 -t dhh/app:latest --cache-to type=gha --cache-from type=gha --label service=\"app\" --file Dockerfile .", @@ -93,21 +93,21 @@ class CommandsBuilderTest < ActiveSupport::TestCase test "build context" do builder = new_builder_command(builder: { "context" => ".." }) assert_equal \ - "docker build --push --platform linux/amd64,linux/arm64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ..", + "docker build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ..", builder.push.join(" ") end test "push with build args" do builder = new_builder_command(builder: { "args" => { "a" => 1, "b" => 2 } }) assert_equal \ - "docker build --push --platform linux/amd64,linux/arm64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --build-arg a=\"1\" --build-arg b=\"2\" --file Dockerfile .", + "docker build --push --platform linux/amd64 --builder kamal-local-docker-container -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 test "push with build secrets" do builder = new_builder_command(builder: { "secrets" => [ "a", "b" ] }) assert_equal \ - "docker build --push --platform linux/amd64,linux/arm64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --secret id=\"a\" --secret id=\"b\" --file Dockerfile .", + "docker build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --secret id=\"a\" --secret id=\"b\" --file Dockerfile .", builder.push.join(" ") end @@ -126,7 +126,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase test "context build" do builder = new_builder_command(builder: { "context" => "./foo" }) assert_equal \ - "docker build --push --platform linux/amd64,linux/arm64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ./foo", + "docker build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ./foo", builder.push.join(" ") end @@ -137,7 +137,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase private def new_builder_command(additional_config = {}) - Kamal::Commands::Builder.new(Kamal::Configuration.new(@config.merge(additional_config), version: "123")) + Kamal::Commands::Builder.new(Kamal::Configuration.new(@config.deep_merge(additional_config), version: "123")) end def build_directory diff --git a/test/commands/docker_test.rb b/test/commands/docker_test.rb index 0c0e976b9..db2ed45c5 100644 --- a/test/commands/docker_test.rb +++ b/test/commands/docker_test.rb @@ -3,7 +3,7 @@ class CommandsDockerTest < ActiveSupport::TestCase setup do @config = { - service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ] + service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], builder: { "arch" => "amd64" } } @docker = Kamal::Commands::Docker.new(Kamal::Configuration.new(@config)) end diff --git a/test/commands/hook_test.rb b/test/commands/hook_test.rb index c0e6e98fa..60438c66f 100644 --- a/test/commands/hook_test.rb +++ b/test/commands/hook_test.rb @@ -8,7 +8,7 @@ class CommandsHookTest < ActiveSupport::TestCase @config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], - traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } + builder: { "arch" => "amd64" }, traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } } @performer = Kamal::Git.email.presence || `whoami`.chomp diff --git a/test/commands/lock_test.rb b/test/commands/lock_test.rb index fc2b15abb..028719220 100644 --- a/test/commands/lock_test.rb +++ b/test/commands/lock_test.rb @@ -4,7 +4,7 @@ class CommandsLockTest < ActiveSupport::TestCase setup do @config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], - traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } + builder: { "arch" => "amd64" }, traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } } end diff --git a/test/commands/prune_test.rb b/test/commands/prune_test.rb index c4a56a9a2..430a13db6 100644 --- a/test/commands/prune_test.rb +++ b/test/commands/prune_test.rb @@ -4,7 +4,7 @@ class CommandsPruneTest < ActiveSupport::TestCase setup do @config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], - traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } + builder: { "arch" => "amd64" }, traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } } end diff --git a/test/commands/registry_test.rb b/test/commands/registry_test.rb index c25d75853..17376fef9 100755 --- a/test/commands/registry_test.rb +++ b/test/commands/registry_test.rb @@ -8,6 +8,7 @@ class CommandsRegistryTest < ActiveSupport::TestCase "password" => "secret", "server" => "hub.docker.com" }, + builder: { "arch" => "amd64" }, servers: [ "1.1.1.1" ] } @registry = Kamal::Commands::Registry.new Kamal::Configuration.new(@config) diff --git a/test/commands/server_test.rb b/test/commands/server_test.rb index 9e063f77d..8c465fd9d 100644 --- a/test/commands/server_test.rb +++ b/test/commands/server_test.rb @@ -4,7 +4,7 @@ class CommandsServerTest < ActiveSupport::TestCase setup do @config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], - traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } + builder: { "arch" => "amd64" }, traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } } end diff --git a/test/commands/traefik_test.rb b/test/commands/traefik_test.rb index a46fc2845..446c3077e 100644 --- a/test/commands/traefik_test.rb +++ b/test/commands/traefik_test.rb @@ -5,7 +5,7 @@ class CommandsTraefikTest < ActiveSupport::TestCase @image = "traefik:test" @config = { - service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], + service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], builder: { "arch" => "amd64" }, traefik: { "image" => @image, "args" => { "accesslog.format" => "json", "api.insecure" => true, "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } } } diff --git a/test/configuration/accessory_test.rb b/test/configuration/accessory_test.rb index 581cdab34..3f939607d 100644 --- a/test/configuration/accessory_test.rb +++ b/test/configuration/accessory_test.rb @@ -8,6 +8,7 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase "web" => [ "1.1.1.1", "1.1.1.2" ], "workers" => [ "1.1.1.3", "1.1.1.4" ] }, + builder: { "arch" => "amd64" }, env: { "REDIS_URL" => "redis://x/y" }, accessories: { "mysql" => { diff --git a/test/configuration/builder_test.rb b/test/configuration/builder_test.rb index efcd613b5..3df477c95 100644 --- a/test/configuration/builder_test.rb +++ b/test/configuration/builder_test.rb @@ -4,13 +4,7 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase setup do @deploy = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, - servers: [ "1.1.1.1" ] - } - - @deploy_with_builder_option = { - service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, - servers: [ "1.1.1.1" ], - builder: {} + builder: { "arch" => "amd64" }, servers: [ "1.1.1.1" ] } end @@ -27,16 +21,16 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase end test "setting both local and remote configs" do - @deploy_with_builder_option[:builder] = { + @deploy[:builder] = { "arch" => [ "amd64", "arm64" ], "remote" => "ssh://root@192.168.0.1" } - assert_equal true, config_with_builder_option.builder.local? - assert_equal true, config_with_builder_option.builder.remote? + assert_equal true, config.builder.local? + assert_equal true, config.builder.remote? - assert_equal [ "amd64", "arm64" ], config_with_builder_option.builder.arches - assert_equal "ssh://root@192.168.0.1", config_with_builder_option.builder.remote + assert_equal [ "amd64", "arm64" ], config.builder.arches + assert_equal "ssh://root@192.168.0.1", config.builder.remote end test "cached?" do @@ -44,10 +38,10 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase end test "invalid cache type specified" do - @deploy_with_builder_option[:builder] = { "cache" => { "type" => "invalid" } } + @deploy[:builder]["cache"] = { "type" => "invalid" } assert_raises(Kamal::ConfigurationError) do - config_with_builder_option.builder + config.builder end end @@ -60,32 +54,32 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase end test "setting gha cache" do - @deploy_with_builder_option[:builder] = { "cache" => { "type" => "gha", "options" => "mode=max" } } + @deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "gha", "options" => "mode=max" } } - assert_equal "type=gha", config_with_builder_option.builder.cache_from - assert_equal "type=gha,mode=max", config_with_builder_option.builder.cache_to + assert_equal "type=gha", config.builder.cache_from + assert_equal "type=gha,mode=max", config.builder.cache_to end test "setting registry cache" do - @deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } } + @deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } } - assert_equal "type=registry,ref=dhh/app-build-cache", config_with_builder_option.builder.cache_from - assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=dhh/app-build-cache", config_with_builder_option.builder.cache_to + assert_equal "type=registry,ref=dhh/app-build-cache", config.builder.cache_from + assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=dhh/app-build-cache", config.builder.cache_to end test "setting registry cache when using a custom registry" do - @deploy_with_builder_option[:registry]["server"] = "registry.example.com" - @deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } } + @deploy[:registry]["server"] = "registry.example.com" + @deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } } - assert_equal "type=registry,ref=registry.example.com/dhh/app-build-cache", config_with_builder_option.builder.cache_from - assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=registry.example.com/dhh/app-build-cache", config_with_builder_option.builder.cache_to + assert_equal "type=registry,ref=registry.example.com/dhh/app-build-cache", config.builder.cache_from + assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=registry.example.com/dhh/app-build-cache", config.builder.cache_to end test "setting registry cache with image" do - @deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "image" => "kamal", "options" => "mode=max" } } + @deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "registry", "image" => "kamal", "options" => "mode=max" } } - assert_equal "type=registry,ref=kamal", config_with_builder_option.builder.cache_from - assert_equal "type=registry,mode=max,ref=kamal", config_with_builder_option.builder.cache_to + assert_equal "type=registry,ref=kamal", config.builder.cache_from + assert_equal "type=registry,mode=max,ref=kamal", config.builder.cache_to end test "args" do @@ -93,9 +87,9 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase end test "setting args" do - @deploy_with_builder_option[:builder] = { "args" => { "key" => "value" } } + @deploy[:builder]["args"] = { "key" => "value" } - assert_equal({ "key" => "value" }, config_with_builder_option.builder.args) + assert_equal({ "key" => "value" }, config.builder.args) end test "secrets" do @@ -103,9 +97,9 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase end test "setting secrets" do - @deploy_with_builder_option[:builder] = { "secrets" => [ "GITHUB_TOKEN" ] } + @deploy[:builder]["secrets"] = [ "GITHUB_TOKEN" ] - assert_equal [ "GITHUB_TOKEN" ], config_with_builder_option.builder.secrets + assert_equal [ "GITHUB_TOKEN" ], config.builder.secrets end test "dockerfile" do @@ -113,9 +107,9 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase end test "setting dockerfile" do - @deploy_with_builder_option[:builder] = { "dockerfile" => "Dockerfile.dev" } + @deploy[:builder]["dockerfile"] = "Dockerfile.dev" - assert_equal "Dockerfile.dev", config_with_builder_option.builder.dockerfile + assert_equal "Dockerfile.dev", config.builder.dockerfile end test "context" do @@ -123,9 +117,9 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase end test "setting context" do - @deploy_with_builder_option[:builder] = { "context" => ".." } + @deploy[:builder]["context"] = ".." - assert_equal "..", config_with_builder_option.builder.context + assert_equal "..", config.builder.context end test "ssh" do @@ -133,17 +127,13 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase end test "setting ssh params" do - @deploy_with_builder_option[:builder] = { "ssh" => "default=$SSH_AUTH_SOCK" } + @deploy[:builder]["ssh"] = "default=$SSH_AUTH_SOCK" - assert_equal "default=$SSH_AUTH_SOCK", config_with_builder_option.builder.ssh + assert_equal "default=$SSH_AUTH_SOCK", config.builder.ssh end private def config Kamal::Configuration.new(@deploy) end - - def config_with_builder_option - Kamal::Configuration.new(@deploy_with_builder_option) - end end diff --git a/test/configuration/env/tags_test.rb b/test/configuration/env/tags_test.rb index c36b6057b..0fb649d1d 100644 --- a/test/configuration/env/tags_test.rb +++ b/test/configuration/env/tags_test.rb @@ -5,6 +5,7 @@ class ConfigurationEnvTagsTest < ActiveSupport::TestCase @deploy = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ { "1.1.1.1" => "odd" }, { "1.1.1.2" => "even" }, { "1.1.1.3" => [ "odd", "three" ] } ], + builder: { "arch" => "amd64" }, env: { "clear" => { "REDIS_URL" => "redis://x/y", "THREE" => "false" }, "tags" => { @@ -64,6 +65,7 @@ class ConfigurationEnvTagsTest < ActiveSupport::TestCase deploy = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ { "1.1.1.1" => [ "first", "second" ] } ], + builder: { "arch" => "amd64" }, env: { "tags" => { "first" => { "TYPE" => "first" }, @@ -82,6 +84,7 @@ class ConfigurationEnvTagsTest < ActiveSupport::TestCase deploy = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ { "1.1.1.1" => "secrets" } ], + builder: { "arch" => "amd64" }, env: { "tags" => { "secrets" => { "secret" => [ "PASSWORD" ] } @@ -99,6 +102,7 @@ class ConfigurationEnvTagsTest < ActiveSupport::TestCase deploy = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ { "1.1.1.1" => "clearly" } ], + builder: { "arch" => "amd64" }, env: { "tags" => { "clearly" => { "clear" => { "FOO" => "bar" } } diff --git a/test/configuration/role_test.rb b/test/configuration/role_test.rb index da9a3d1c5..37c26fcdf 100644 --- a/test/configuration/role_test.rb +++ b/test/configuration/role_test.rb @@ -5,6 +5,7 @@ class ConfigurationRoleTest < ActiveSupport::TestCase @deploy = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1", "1.1.1.2" ], + builder: { "arch" => "amd64" }, env: { "REDIS_URL" => "redis://x/y" } } diff --git a/test/configuration/ssh_test.rb b/test/configuration/ssh_test.rb index f49c00559..76d1ae9a7 100644 --- a/test/configuration/ssh_test.rb +++ b/test/configuration/ssh_test.rb @@ -5,6 +5,7 @@ class ConfigurationSshTest < ActiveSupport::TestCase @deploy = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, + builder: { "arch" => "amd64" }, env: { "REDIS_URL" => "redis://x/y" }, servers: [ "1.1.1.1", "1.1.1.2" ], volumes: [ "/local/path:/container/path" ] diff --git a/test/configuration/sshkit_test.rb b/test/configuration/sshkit_test.rb index dc8c22580..1608e6eee 100644 --- a/test/configuration/sshkit_test.rb +++ b/test/configuration/sshkit_test.rb @@ -6,6 +6,7 @@ class ConfigurationSshkitTest < ActiveSupport::TestCase service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, env: { "REDIS_URL" => "redis://x/y" }, + builder: { "arch" => "amd64" }, servers: [ "1.1.1.1", "1.1.1.2" ], volumes: [ "/local/path:/container/path" ] } diff --git a/test/configuration/validation_test.rb b/test/configuration/validation_test.rb index b39dbc369..ac409e845 100644 --- a/test/configuration/validation_test.rb +++ b/test/configuration/validation_test.rb @@ -101,6 +101,7 @@ def assert_error(message, **invalid_config) valid_config = { service: "app", image: "app", + builder: { "arch" => "amd64" }, registry: { "username" => "user", "password" => "secret" }, servers: [ "1.1.1.1" ] } diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 043a4c8cb..aa78dda98 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -8,6 +8,7 @@ class ConfigurationTest < ActiveSupport::TestCase @deploy = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, + builder: { "arch" => "amd64" }, env: { "REDIS_URL" => "redis://x/y" }, servers: [ "1.1.1.1", "1.1.1.2" ], volumes: [ "/local/path:/container/path" ] @@ -121,7 +122,7 @@ class ConfigurationTest < ActiveSupport::TestCase test "version from uncommitted context" do ENV.delete("VERSION") - config = Kamal::Configuration.new(@deploy.tap { |c| c[:builder] = { "context" => "." } }) + config = Kamal::Configuration.new(@deploy.tap { |c| c[:builder]["context"] = "." }) Kamal::Git.expects(:revision).returns("git-version") Kamal::Git.expects(:uncommitted_changes).returns("M file\n") @@ -267,7 +268,7 @@ class ConfigurationTest < ActiveSupport::TestCase ssh_options: { user: "root", port: 22, log_level: :fatal, keepalive: true, keepalive_interval: 30 }, sshkit: {}, volume_args: [ "--volume", "/local/path:/container/path" ], - builder: {}, + builder: { "arch" => "amd64" }, logging: [ "--log-opt", "max-size=\"10m\"" ], healthcheck: { "cmd"=>"curl -f http://localhost:3000/up || exit 1", "interval" => "1s", "path"=>"/up", "port"=>3000, "max_attempts" => 7, "cord" => "/tmp/kamal-cord", "log_lines" => 50 } } diff --git a/test/fixtures/deploy.erb.yml b/test/fixtures/deploy.erb.yml index a668fb3a6..9b9d202d0 100644 --- a/test/fixtures/deploy.erb.yml +++ b/test/fixtures/deploy.erb.yml @@ -9,3 +9,5 @@ registry: server: registry.digitalocean.com username: <%= "my-user" %> password: <%= "my-password" %> +builder: + arch: amd64 diff --git a/test/fixtures/deploy_for_dest.yml b/test/fixtures/deploy_for_dest.yml index 96740aecf..1784d95f9 100644 --- a/test/fixtures/deploy_for_dest.yml +++ b/test/fixtures/deploy_for_dest.yml @@ -4,3 +4,5 @@ registry: server: registry.digitalocean.com username: <%= "my-user" %> password: <%= "my-password" %> +builder: + arch: amd64 diff --git a/test/fixtures/deploy_for_required_dest.yml b/test/fixtures/deploy_for_required_dest.yml index 284383636..1102df953 100644 --- a/test/fixtures/deploy_for_required_dest.yml +++ b/test/fixtures/deploy_for_required_dest.yml @@ -4,4 +4,6 @@ registry: server: registry.digitalocean.com username: <%= "my-user" %> password: <%= "my-password" %> +builder: + arch: amd64 require_destination: true diff --git a/test/fixtures/deploy_primary_web_role_override.yml b/test/fixtures/deploy_primary_web_role_override.yml index 694a9be7e..aa52f5edd 100644 --- a/test/fixtures/deploy_primary_web_role_override.yml +++ b/test/fixtures/deploy_primary_web_role_override.yml @@ -17,4 +17,6 @@ registry: server: registry.digitalocean.com username: user password: pw +builder: + arch: amd64 primary_role: web_tokyo diff --git a/test/fixtures/deploy_simple.yml b/test/fixtures/deploy_simple.yml index 520c138e9..c143f800d 100644 --- a/test/fixtures/deploy_simple.yml +++ b/test/fixtures/deploy_simple.yml @@ -6,3 +6,5 @@ servers: registry: username: user password: pw +builder: + arch: amd64 diff --git a/test/fixtures/deploy_with_accessories.yml b/test/fixtures/deploy_with_accessories.yml index dd78e9f47..29f502ece 100644 --- a/test/fixtures/deploy_with_accessories.yml +++ b/test/fixtures/deploy_with_accessories.yml @@ -10,6 +10,8 @@ servers: registry: username: user password: pw +builder: + arch: amd64 accessories: mysql: diff --git a/test/fixtures/deploy_with_assets.yml b/test/fixtures/deploy_with_assets.yml index 0b6b7cf52..2879d445c 100644 --- a/test/fixtures/deploy_with_assets.yml +++ b/test/fixtures/deploy_with_assets.yml @@ -6,4 +6,6 @@ servers: registry: username: user password: pw +builder: + arch: amd64 asset_path: /public/assets diff --git a/test/fixtures/deploy_with_boot_strategy.yml b/test/fixtures/deploy_with_boot_strategy.yml index 7691eb2e1..963bb7c34 100644 --- a/test/fixtures/deploy_with_boot_strategy.yml +++ b/test/fixtures/deploy_with_boot_strategy.yml @@ -7,6 +7,8 @@ servers: workers: - "1.1.1.3" - "1.1.1.4" +builder: + arch: amd64 registry: username: user diff --git a/test/fixtures/deploy_with_env_tags.yml b/test/fixtures/deploy_with_env_tags.yml index f0a247603..6822b49d8 100644 --- a/test/fixtures/deploy_with_env_tags.yml +++ b/test/fixtures/deploy_with_env_tags.yml @@ -11,6 +11,8 @@ servers: - 1.1.1.4: site1 - 1.2.1.3: site2 - 1.2.1.4: [ site2 experimental ] +builder: + arch: amd64 env: clear: TEST: "root" diff --git a/test/fixtures/deploy_with_extensions.yml b/test/fixtures/deploy_with_extensions.yml index 7d6a9db27..4a5f934a5 100644 --- a/test/fixtures/deploy_with_extensions.yml +++ b/test/fixtures/deploy_with_extensions.yml @@ -21,4 +21,6 @@ registry: server: registry.digitalocean.com username: user password: pw +builder: + arch: amd64 primary_role: web_tokyo diff --git a/test/fixtures/deploy_with_low_percentage_boot_strategy.yml b/test/fixtures/deploy_with_low_percentage_boot_strategy.yml index 9b6a3c647..8698b89fe 100644 --- a/test/fixtures/deploy_with_low_percentage_boot_strategy.yml +++ b/test/fixtures/deploy_with_low_percentage_boot_strategy.yml @@ -7,6 +7,8 @@ servers: workers: - "1.1.1.3" - "1.1.1.4" +builder: + arch: amd64 registry: username: user diff --git a/test/fixtures/deploy_with_multiple_traefik_roles.yml b/test/fixtures/deploy_with_multiple_traefik_roles.yml index a36a409f1..a12705831 100644 --- a/test/fixtures/deploy_with_multiple_traefik_roles.yml +++ b/test/fixtures/deploy_with_multiple_traefik_roles.yml @@ -26,6 +26,8 @@ servers: hosts: - 1.1.1.3 - 1.1.1.4 +builder: + arch: amd64 env: REDIS_URL: redis://x/y registry: diff --git a/test/fixtures/deploy_with_percentage_boot_strategy.yml b/test/fixtures/deploy_with_percentage_boot_strategy.yml index 9b6a3c647..8698b89fe 100644 --- a/test/fixtures/deploy_with_percentage_boot_strategy.yml +++ b/test/fixtures/deploy_with_percentage_boot_strategy.yml @@ -7,6 +7,8 @@ servers: workers: - "1.1.1.3" - "1.1.1.4" +builder: + arch: amd64 registry: username: user diff --git a/test/fixtures/deploy_with_remote_builder.yml b/test/fixtures/deploy_with_remote_builder.yml index a67963c2a..118142f74 100644 --- a/test/fixtures/deploy_with_remote_builder.yml +++ b/test/fixtures/deploy_with_remote_builder.yml @@ -32,6 +32,8 @@ accessories: port: 6379 directories: - data:/data +builder: + arch: amd64 readiness_delay: 0 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 d76100ff6..0f409da4a 100644 --- a/test/fixtures/deploy_with_remote_builder_and_custom_ports.yml +++ b/test/fixtures/deploy_with_remote_builder_and_custom_ports.yml @@ -32,6 +32,8 @@ accessories: port: 6379 directories: - data:/data +builder: + arch: amd64 readiness_delay: 0 diff --git a/test/fixtures/deploy_with_roles.yml b/test/fixtures/deploy_with_roles.yml index 0e405241d..1eb8cc5c0 100644 --- a/test/fixtures/deploy_with_roles.yml +++ b/test/fixtures/deploy_with_roles.yml @@ -14,3 +14,5 @@ registry: server: registry.digitalocean.com username: user password: pw +builder: + arch: amd64 diff --git a/test/fixtures/deploy_with_secrets.yml b/test/fixtures/deploy_with_secrets.yml index a03cecbf8..35145a3e2 100644 --- a/test/fixtures/deploy_with_secrets.yml +++ b/test/fixtures/deploy_with_secrets.yml @@ -9,3 +9,5 @@ registry: env: secret: - PASSWORD +builder: + arch: amd64 diff --git a/test/fixtures/deploy_with_two_roles_one_host.yml b/test/fixtures/deploy_with_two_roles_one_host.yml index cae054698..939ff7e5e 100644 --- a/test/fixtures/deploy_with_two_roles_one_host.yml +++ b/test/fixtures/deploy_with_two_roles_one_host.yml @@ -13,3 +13,5 @@ registry: server: registry.digitalocean.com username: user password: pw +builder: + arch: amd64 diff --git a/test/fixtures/deploy_with_uncommon_hostnames.yml b/test/fixtures/deploy_with_uncommon_hostnames.yml index 71e7a6018..112f7b394 100644 --- a/test/fixtures/deploy_with_uncommon_hostnames.yml +++ b/test/fixtures/deploy_with_uncommon_hostnames.yml @@ -6,3 +6,5 @@ servers: registry: username: user password: pw +builder: + arch: amd64 diff --git a/test/fixtures/deploy_without_clone.yml b/test/fixtures/deploy_without_clone.yml index abb1224a1..c322155fb 100644 --- a/test/fixtures/deploy_without_clone.yml +++ b/test/fixtures/deploy_without_clone.yml @@ -36,4 +36,5 @@ accessories: readiness_delay: 0 builder: + arch: amd64 context: "." diff --git a/test/fixtures/deploy_workers_only.yml b/test/fixtures/deploy_workers_only.yml index 75cbbde1a..d83adeeb7 100644 --- a/test/fixtures/deploy_workers_only.yml +++ b/test/fixtures/deploy_workers_only.yml @@ -10,3 +10,5 @@ primary_role: workers registry: username: user password: pw +builder: + arch: amd64