Require an arch to be set, and default to amd64 in the template

This commit is contained in:
Donal McBreen
2024-08-28 11:35:39 +01:00
parent 56268d724d
commit d2d0223c37
46 changed files with 118 additions and 77 deletions

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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" } }
}

View File

@@ -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" => {

View File

@@ -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

View File

@@ -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" } }

View File

@@ -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" }
}

View File

@@ -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" ]

View File

@@ -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" ]
}

View File

@@ -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" ]
}

View File

@@ -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 } }

View File

@@ -9,3 +9,5 @@ registry:
server: registry.digitalocean.com
username: <%= "my-user" %>
password: <%= "my-password" %>
builder:
arch: amd64

View File

@@ -4,3 +4,5 @@ registry:
server: registry.digitalocean.com
username: <%= "my-user" %>
password: <%= "my-password" %>
builder:
arch: amd64

View File

@@ -4,4 +4,6 @@ registry:
server: registry.digitalocean.com
username: <%= "my-user" %>
password: <%= "my-password" %>
builder:
arch: amd64
require_destination: true

View File

@@ -17,4 +17,6 @@ registry:
server: registry.digitalocean.com
username: user
password: pw
builder:
arch: amd64
primary_role: web_tokyo

View File

@@ -6,3 +6,5 @@ servers:
registry:
username: user
password: pw
builder:
arch: amd64

View File

@@ -10,6 +10,8 @@ servers:
registry:
username: user
password: pw
builder:
arch: amd64
accessories:
mysql:

View File

@@ -6,4 +6,6 @@ servers:
registry:
username: user
password: pw
builder:
arch: amd64
asset_path: /public/assets

View File

@@ -7,6 +7,8 @@ servers:
workers:
- "1.1.1.3"
- "1.1.1.4"
builder:
arch: amd64
registry:
username: user

View File

@@ -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"

View File

@@ -21,4 +21,6 @@ registry:
server: registry.digitalocean.com
username: user
password: pw
builder:
arch: amd64
primary_role: web_tokyo

View File

@@ -7,6 +7,8 @@ servers:
workers:
- "1.1.1.3"
- "1.1.1.4"
builder:
arch: amd64
registry:
username: user

View File

@@ -26,6 +26,8 @@ servers:
hosts:
- 1.1.1.3
- 1.1.1.4
builder:
arch: amd64
env:
REDIS_URL: redis://x/y
registry:

View File

@@ -7,6 +7,8 @@ servers:
workers:
- "1.1.1.3"
- "1.1.1.4"
builder:
arch: amd64
registry:
username: user

View File

@@ -32,6 +32,8 @@ accessories:
port: 6379
directories:
- data:/data
builder:
arch: amd64
readiness_delay: 0

View File

@@ -32,6 +32,8 @@ accessories:
port: 6379
directories:
- data:/data
builder:
arch: amd64
readiness_delay: 0

View File

@@ -14,3 +14,5 @@ registry:
server: registry.digitalocean.com
username: user
password: pw
builder:
arch: amd64

View File

@@ -9,3 +9,5 @@ registry:
env:
secret:
- PASSWORD
builder:
arch: amd64

View File

@@ -13,3 +13,5 @@ registry:
server: registry.digitalocean.com
username: user
password: pw
builder:
arch: amd64

View File

@@ -6,3 +6,5 @@ servers:
registry:
username: user
password: pw
builder:
arch: amd64

View File

@@ -36,4 +36,5 @@ accessories:
readiness_delay: 0
builder:
arch: amd64
context: "."

View File

@@ -10,3 +10,5 @@ primary_role: workers
registry:
username: user
password: pw
builder:
arch: amd64

View File

@@ -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:

View File

@@ -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:

View File

@@ -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