Add build args

This commit is contained in:
David Heinemeier Hansson
2023-01-15 10:35:15 +01:00
parent 53cd13a0fa
commit bafbde52fe
6 changed files with 64 additions and 19 deletions

View File

@@ -0,0 +1,18 @@
require "mrsk/commands/base"
class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
delegate :argumentize, to: Mrsk::Configuration
def pull
docker :pull, config.absolute_image
end
def build_args
argumentize "--build-args", args
end
private
def args
config.builder["args"] || {}
end
end

View File

@@ -1,6 +1,6 @@
require "mrsk/commands/base"
require "mrsk/commands/builder/base"
class Mrsk::Commands::Builder::Multiarch < Mrsk::Commands::Base
class Mrsk::Commands::Builder::Multiarch < Mrsk::Commands::Builder::Base
def create
docker :buildx, :create, "--use", "--name", builder_name
end
@@ -10,11 +10,7 @@ class Mrsk::Commands::Builder::Multiarch < Mrsk::Commands::Base
end
def push
docker :buildx, :build, "--push", "--platform linux/amd64,linux/arm64", "-t", config.absolute_image, "."
end
def pull
docker :pull, config.absolute_image
docker :buildx, :build, "--push", "--platform linux/amd64,linux/arm64", "-t", config.absolute_image, *build_args, "."
end
def info

View File

@@ -1,6 +1,6 @@
require "mrsk/commands/base"
require "mrsk/commands/builder/base"
class Mrsk::Commands::Builder::Native < Mrsk::Commands::Base
class Mrsk::Commands::Builder::Native < Mrsk::Commands::Builder::Base
def create
# No-op on native
end
@@ -11,14 +11,10 @@ class Mrsk::Commands::Builder::Native < Mrsk::Commands::Base
def push
combine \
docker(:build, "-t", config.absolute_image, "."),
docker(:build, "-t", *build_args, config.absolute_image, "."),
docker(:push, config.absolute_image)
end
def pull
docker :pull, config.absolute_image
end
def info
# No-op on native
end