-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduce a
build push --output
option
which controls where the build result is exported. The default value is "registry" to reflect the current behavior of `build push`. Any value provided to this option will be passed to the `buildx build` command as a `--output=type=<VALUE>` flag. For example, the following command will push to the local docker image store: kamal build push --output=docker squash
- Loading branch information
1 parent
5f04e42
commit 24e4347
Showing
4 changed files
with
49 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,63 +9,63 @@ class CommandsBuilderTest < ActiveSupport::TestCase | |
builder = new_builder_command(builder: { "cache" => { "type" => "gha" } }) | ||
assert_equal "local", builder.name | ||
assert_equal \ | ||
"docker buildx 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 .", | ||
"docker buildx build --output=type=registry --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 "target specified arch locally by default" do | ||
builder = new_builder_command(builder: { "arch" => [ "amd64" ] }) | ||
assert_equal "local", builder.name | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile .", | ||
"docker buildx build --output=type=registry --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 "build with caching" do | ||
builder = new_builder_command(builder: { "cache" => { "type" => "gha" } }) | ||
assert_equal "local", builder.name | ||
assert_equal \ | ||
"docker buildx 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 .", | ||
"docker buildx build --output=type=registry --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 and building multiarch" do | ||
builder = new_builder_command(builder: { "arch" => [ "amd64", "arm64" ], "remote" => "ssh://[email protected]", "cache" => { "type" => "gha" } }) | ||
assert_equal "hybrid", builder.name | ||
assert_equal \ | ||
"docker buildx 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 .", | ||
"docker buildx build --output=type=registry --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 .", | ||
builder.push.join(" ") | ||
end | ||
|
||
test "remote build if remote is set and local disabled" do | ||
builder = new_builder_command(builder: { "arch" => [ "amd64", "arm64" ], "remote" => "ssh://[email protected]", "cache" => { "type" => "gha" }, "local" => false }) | ||
assert_equal "remote", builder.name | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/amd64,linux/arm64 --builder kamal-remote-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 .", | ||
"docker buildx build --output=type=registry --platform linux/amd64,linux/arm64 --builder kamal-remote-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 .", | ||
builder.push.join(" ") | ||
end | ||
|
||
test "target remote when remote set and arch is non local" do | ||
builder = new_builder_command(builder: { "arch" => [ "#{remote_arch}" ], "remote" => "ssh://app@host", "cache" => { "type" => "gha" } }) | ||
assert_equal "remote", builder.name | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/#{remote_arch} --builder kamal-remote-ssh---app-host -t dhh/app:123 -t dhh/app:latest --cache-to type=gha --cache-from type=gha --label service=\"app\" --file Dockerfile .", | ||
"docker buildx build --output=type=registry --platform linux/#{remote_arch} --builder kamal-remote-ssh---app-host -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 "target local when remote set and arch is local" do | ||
builder = new_builder_command(builder: { "arch" => [ "#{local_arch}" ], "remote" => "ssh://app@host", "cache" => { "type" => "gha" } }) | ||
assert_equal "local", builder.name | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/#{local_arch} --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 buildx build --output=type=registry --platform linux/#{local_arch} --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 "cloud builder" do | ||
builder = new_builder_command(builder: { "arch" => [ "#{local_arch}" ], "driver" => "cloud docker-org-name/builder-name" }) | ||
assert_equal "cloud", builder.name | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/#{local_arch} --builder cloud-docker-org-name-builder-name -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile .", | ||
"docker buildx build --output=type=registry --platform linux/#{local_arch} --builder cloud-docker-org-name-builder-name -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile .", | ||
builder.push.join(" ") | ||
end | ||
|
||
|
@@ -112,14 +112,14 @@ class CommandsBuilderTest < ActiveSupport::TestCase | |
test "build context" do | ||
builder = new_builder_command(builder: { "context" => ".." }) | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ..", | ||
"docker buildx build --output=type=registry --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 buildx 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 .", | ||
"docker buildx build --output=type=registry --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 | ||
|
||
|
@@ -128,7 +128,7 @@ class CommandsBuilderTest < ActiveSupport::TestCase | |
FileUtils.touch("Dockerfile") | ||
builder = new_builder_command(builder: { "secrets" => [ "a", "b" ] }) | ||
assert_equal \ | ||
"docker buildx 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 .", | ||
"docker buildx build --output=type=registry --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 | ||
end | ||
|
@@ -148,35 +148,35 @@ class CommandsBuilderTest < ActiveSupport::TestCase | |
test "context build" do | ||
builder = new_builder_command(builder: { "context" => "./foo" }) | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ./foo", | ||
"docker buildx build --output=type=registry --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 | ||
|
||
test "push with provenance" do | ||
builder = new_builder_command(builder: { "provenance" => "mode=max" }) | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile --provenance mode=max .", | ||
"docker buildx build --output=type=registry --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile --provenance mode=max .", | ||
builder.push.join(" ") | ||
end | ||
|
||
test "push with provenance false" do | ||
builder = new_builder_command(builder: { "provenance" => false }) | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile --provenance false .", | ||
"docker buildx build --output=type=registry --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile --provenance false .", | ||
builder.push.join(" ") | ||
end | ||
|
||
test "push with sbom" do | ||
builder = new_builder_command(builder: { "sbom" => true }) | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile --sbom true .", | ||
"docker buildx build --output=type=registry --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile --sbom true .", | ||
builder.push.join(" ") | ||
end | ||
|
||
test "push with sbom false" do | ||
builder = new_builder_command(builder: { "sbom" => false }) | ||
assert_equal \ | ||
"docker buildx build --push --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile --sbom false .", | ||
"docker buildx build --output=type=registry --platform linux/amd64 --builder kamal-local-docker-container -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile --sbom false .", | ||
builder.push.join(" ") | ||
end | ||
|
||
|