Allow setting the build context used for building
This commit is contained in:
@@ -12,6 +12,9 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
|||||||
def build_options
|
def build_options
|
||||||
[ *build_tags, *build_labels, *build_args, *build_secrets, *build_dockerfile ]
|
[ *build_tags, *build_labels, *build_args, *build_secrets, *build_dockerfile ]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_context
|
||||||
|
context
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -46,4 +49,8 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
|||||||
def dockerfile
|
def dockerfile
|
||||||
(config.builder && config.builder["dockerfile"]) || "Dockerfile"
|
(config.builder && config.builder["dockerfile"]) || "Dockerfile"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def context
|
||||||
|
(config.builder && config.builder["context"]) || "."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Mrsk::Commands::Builder::Multiarch < Mrsk::Commands::Builder::Base
|
|||||||
"--platform", "linux/amd64,linux/arm64",
|
"--platform", "linux/amd64,linux/arm64",
|
||||||
"--builder", builder_name,
|
"--builder", builder_name,
|
||||||
*build_options,
|
*build_options,
|
||||||
"."
|
build_context
|
||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Mrsk::Commands::Builder::Native < Mrsk::Commands::Builder::Base
|
|||||||
|
|
||||||
def push
|
def push
|
||||||
combine \
|
combine \
|
||||||
docker(:build, *build_options, "."),
|
docker(:build, *build_options, build_context),
|
||||||
docker(:push, config.absolute_image)
|
docker(:push, config.absolute_image)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Mrsk::Commands::Builder::Native::Remote < Mrsk::Commands::Builder::Native
|
|||||||
"--platform", platform,
|
"--platform", platform,
|
||||||
"--builder", builder_name,
|
"--builder", builder_name,
|
||||||
*build_options,
|
*build_options,
|
||||||
"."
|
build_context
|
||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
|
|||||||
@@ -58,6 +58,13 @@ class CommandsBuilderTest < ActiveSupport::TestCase
|
|||||||
builder.target.build_options.join(" ")
|
builder.target.build_options.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "build context" do
|
||||||
|
builder = new_builder_command(builder: { "context" => ".." })
|
||||||
|
assert_equal \
|
||||||
|
"docker buildx build --push --platform linux/amd64,linux/arm64 --builder mrsk-app-multiarch -t dhh/app:123 -t dhh/app:latest --label service=\"app\" --file Dockerfile ..",
|
||||||
|
builder.push.join(" ")
|
||||||
|
end
|
||||||
|
|
||||||
test "native push with build args" do
|
test "native push with build args" do
|
||||||
builder = new_builder_command(builder: { "multiarch" => false, "args" => { "a" => 1, "b" => 2 } })
|
builder = new_builder_command(builder: { "multiarch" => false, "args" => { "a" => 1, "b" => 2 } })
|
||||||
assert_equal \
|
assert_equal \
|
||||||
|
|||||||
Reference in New Issue
Block a user