Require an arch to be set, and default to amd64 in the template
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,14 +2,14 @@ require "test_helper"
|
||||
|
||||
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
|
||||
|
||||
@@ -3,7 +3,7 @@ require "test_helper"
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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" } }
|
||||
}
|
||||
|
||||
|
||||
@@ -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" => {
|
||||
|
||||
@@ -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
|
||||
|
||||
4
test/configuration/env/tags_test.rb
vendored
4
test/configuration/env/tags_test.rb
vendored
@@ -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" } }
|
||||
|
||||
@@ -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" }
|
||||
}
|
||||
|
||||
|
||||
@@ -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" ]
|
||||
|
||||
@@ -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" ]
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ class ConfigurationValidationTest < ActiveSupport::TestCase
|
||||
valid_config = {
|
||||
service: "app",
|
||||
image: "app",
|
||||
builder: { "arch" => "amd64" },
|
||||
registry: { "username" => "user", "password" => "secret" },
|
||||
servers: [ "1.1.1.1" ]
|
||||
}
|
||||
|
||||
@@ -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 } }
|
||||
|
||||
|
||||
2
test/fixtures/deploy.erb.yml
vendored
2
test/fixtures/deploy.erb.yml
vendored
@@ -9,3 +9,5 @@ registry:
|
||||
server: registry.digitalocean.com
|
||||
username: <%= "my-user" %>
|
||||
password: <%= "my-password" %>
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
2
test/fixtures/deploy_for_dest.yml
vendored
2
test/fixtures/deploy_for_dest.yml
vendored
@@ -4,3 +4,5 @@ registry:
|
||||
server: registry.digitalocean.com
|
||||
username: <%= "my-user" %>
|
||||
password: <%= "my-password" %>
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
2
test/fixtures/deploy_for_required_dest.yml
vendored
2
test/fixtures/deploy_for_required_dest.yml
vendored
@@ -4,4 +4,6 @@ registry:
|
||||
server: registry.digitalocean.com
|
||||
username: <%= "my-user" %>
|
||||
password: <%= "my-password" %>
|
||||
builder:
|
||||
arch: amd64
|
||||
require_destination: true
|
||||
|
||||
@@ -17,4 +17,6 @@ registry:
|
||||
server: registry.digitalocean.com
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
primary_role: web_tokyo
|
||||
|
||||
2
test/fixtures/deploy_simple.yml
vendored
2
test/fixtures/deploy_simple.yml
vendored
@@ -6,3 +6,5 @@ servers:
|
||||
registry:
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
2
test/fixtures/deploy_with_accessories.yml
vendored
2
test/fixtures/deploy_with_accessories.yml
vendored
@@ -10,6 +10,8 @@ servers:
|
||||
registry:
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
accessories:
|
||||
mysql:
|
||||
|
||||
2
test/fixtures/deploy_with_assets.yml
vendored
2
test/fixtures/deploy_with_assets.yml
vendored
@@ -6,4 +6,6 @@ servers:
|
||||
registry:
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
asset_path: /public/assets
|
||||
|
||||
2
test/fixtures/deploy_with_boot_strategy.yml
vendored
2
test/fixtures/deploy_with_boot_strategy.yml
vendored
@@ -7,6 +7,8 @@ servers:
|
||||
workers:
|
||||
- "1.1.1.3"
|
||||
- "1.1.1.4"
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
registry:
|
||||
username: user
|
||||
|
||||
2
test/fixtures/deploy_with_env_tags.yml
vendored
2
test/fixtures/deploy_with_env_tags.yml
vendored
@@ -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"
|
||||
|
||||
2
test/fixtures/deploy_with_extensions.yml
vendored
2
test/fixtures/deploy_with_extensions.yml
vendored
@@ -21,4 +21,6 @@ registry:
|
||||
server: registry.digitalocean.com
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
primary_role: web_tokyo
|
||||
|
||||
@@ -7,6 +7,8 @@ servers:
|
||||
workers:
|
||||
- "1.1.1.3"
|
||||
- "1.1.1.4"
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
registry:
|
||||
username: user
|
||||
|
||||
@@ -26,6 +26,8 @@ servers:
|
||||
hosts:
|
||||
- 1.1.1.3
|
||||
- 1.1.1.4
|
||||
builder:
|
||||
arch: amd64
|
||||
env:
|
||||
REDIS_URL: redis://x/y
|
||||
registry:
|
||||
|
||||
@@ -7,6 +7,8 @@ servers:
|
||||
workers:
|
||||
- "1.1.1.3"
|
||||
- "1.1.1.4"
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
registry:
|
||||
username: user
|
||||
|
||||
2
test/fixtures/deploy_with_remote_builder.yml
vendored
2
test/fixtures/deploy_with_remote_builder.yml
vendored
@@ -32,6 +32,8 @@ accessories:
|
||||
port: 6379
|
||||
directories:
|
||||
- data:/data
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
readiness_delay: 0
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ accessories:
|
||||
port: 6379
|
||||
directories:
|
||||
- data:/data
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
readiness_delay: 0
|
||||
|
||||
|
||||
2
test/fixtures/deploy_with_roles.yml
vendored
2
test/fixtures/deploy_with_roles.yml
vendored
@@ -14,3 +14,5 @@ registry:
|
||||
server: registry.digitalocean.com
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
2
test/fixtures/deploy_with_secrets.yml
vendored
2
test/fixtures/deploy_with_secrets.yml
vendored
@@ -9,3 +9,5 @@ registry:
|
||||
env:
|
||||
secret:
|
||||
- PASSWORD
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
@@ -13,3 +13,5 @@ registry:
|
||||
server: registry.digitalocean.com
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
@@ -6,3 +6,5 @@ servers:
|
||||
registry:
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
1
test/fixtures/deploy_without_clone.yml
vendored
1
test/fixtures/deploy_without_clone.yml
vendored
@@ -36,4 +36,5 @@ accessories:
|
||||
readiness_delay: 0
|
||||
|
||||
builder:
|
||||
arch: amd64
|
||||
context: "."
|
||||
|
||||
2
test/fixtures/deploy_workers_only.yml
vendored
2
test/fixtures/deploy_workers_only.yml
vendored
@@ -10,3 +10,5 @@ primary_role: workers
|
||||
registry:
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
@@ -24,6 +24,7 @@ registry:
|
||||
password: root
|
||||
builder:
|
||||
driver: docker
|
||||
arch: <%= uname_m = `uname -m`; uname_m == "x86_64" ? "amd64" : uname_m %>
|
||||
args:
|
||||
COMMIT_SHA: <%= `git rev-parse HEAD` %>
|
||||
healthcheck:
|
||||
|
||||
@@ -18,6 +18,7 @@ registry:
|
||||
password: root
|
||||
builder:
|
||||
driver: docker
|
||||
arch: <%= uname_m = `uname -m`; uname_m == "x86_64" ? "amd64" : uname_m %>
|
||||
args:
|
||||
COMMIT_SHA: <%= `git rev-parse HEAD` %>
|
||||
healthcheck:
|
||||
|
||||
@@ -77,7 +77,7 @@ class MainTest < IntegrationTest
|
||||
assert_equal "app-#{version}", config[:service_with_version]
|
||||
assert_equal [], config[:volume_args]
|
||||
assert_equal({ user: "root", port: 22, keepalive: true, keepalive_interval: 30, log_level: :fatal }, config[:ssh_options])
|
||||
assert_equal({ "driver" => "docker", "args" => { "COMMIT_SHA" => version } }, config[:builder])
|
||||
assert_equal({ "driver" => "docker", "arch" => "amd64", "args" => { "COMMIT_SHA" => version } }, config[:builder])
|
||||
assert_equal [ "--log-opt", "max-size=\"10m\"" ], config[:logging]
|
||||
assert_equal({ "cmd"=>"wget -qO- http://localhost > /dev/null || exit 1", "interval"=>"1s", "max_attempts"=>3, "port"=>3000, "path"=>"/up", "cord"=>"/tmp/kamal-cord", "log_lines"=>50 }, config[:healthcheck])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user