Add a pack option to the builder options
This commit is contained in:
@@ -77,6 +77,10 @@ module Kamal::Commands
|
||||
args.compact.unshift :docker
|
||||
end
|
||||
|
||||
def pack(*args)
|
||||
args.compact.unshift :pack
|
||||
end
|
||||
|
||||
def git(*args, path: nil)
|
||||
[ :git, *([ "-C", path ] if path), *args.compact ]
|
||||
end
|
||||
|
||||
@@ -18,6 +18,8 @@ class Kamal::Commands::Builder < Kamal::Commands::Base
|
||||
else
|
||||
native_remote
|
||||
end
|
||||
elsif config.builder.pack?
|
||||
pack
|
||||
else
|
||||
multiarch
|
||||
end
|
||||
@@ -50,6 +52,9 @@ class Kamal::Commands::Builder < Kamal::Commands::Base
|
||||
@multiarch_remote ||= Kamal::Commands::Builder::Multiarch::Remote.new(config)
|
||||
end
|
||||
|
||||
def pack
|
||||
@pack ||= Kamal::Commands::Builder::Native::Pack.new(config)
|
||||
end
|
||||
|
||||
def ensure_local_dependencies_installed
|
||||
if name.native?
|
||||
|
||||
@@ -5,7 +5,7 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base
|
||||
ENDPOINT_DOCKER_HOST_INSPECT = "'{{.Endpoints.docker.Host}}'"
|
||||
|
||||
delegate :argumentize, to: Kamal::Utils
|
||||
delegate :args, :secrets, :dockerfile, :target, :local_arch, :local_host, :remote_arch, :remote_host, :cache_from, :cache_to, :ssh, to: :builder_config
|
||||
delegate :args, :secrets, :dockerfile, :target, :local_arch, :local_host, :pack_arch, :pack_builder, :pack_buildpacks, :remote_arch, :remote_host, :cache_from, :cache_to, :ssh, to: :builder_config
|
||||
|
||||
def clean
|
||||
docker :image, :rm, "--force", config.absolute_image
|
||||
|
||||
26
lib/kamal/commands/builder/native/pack.rb
Normal file
26
lib/kamal/commands/builder/native/pack.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class Kamal::Commands::Builder::Native::Pack < Kamal::Commands::Builder::Native
|
||||
def push
|
||||
combine \
|
||||
pack(:build,
|
||||
config.absolute_image,
|
||||
"--platform", platform,
|
||||
"--builder", pack_builder,
|
||||
buildpacks,
|
||||
"-t", config.absolute_image,
|
||||
"-t", config.latest_image,
|
||||
"--env", "BP_IMAGE_LABELS=service=#{config.service}",
|
||||
secrets.map { |secret| ["--env", Kamal::Utils.sensitive(ENV[secret])] },
|
||||
"--path", build_context),
|
||||
docker(:push, config.absolute_image),
|
||||
docker(:push, config.latest_image)
|
||||
end
|
||||
|
||||
private
|
||||
def platform
|
||||
"linux/#{pack_arch}"
|
||||
end
|
||||
|
||||
def buildpacks
|
||||
(pack_buildpacks << "paketo-buildpacks/image-labels").map { |buildpack| ["--buildpack", buildpack] }
|
||||
end
|
||||
end
|
||||
@@ -35,6 +35,10 @@ class Kamal::Configuration::Builder
|
||||
!!builder_config["cache"]
|
||||
end
|
||||
|
||||
def pack?
|
||||
!!builder_config["pack"]
|
||||
end
|
||||
|
||||
def args
|
||||
builder_config["args"] || {}
|
||||
end
|
||||
@@ -63,6 +67,18 @@ class Kamal::Configuration::Builder
|
||||
builder_config["local"]["host"] if local?
|
||||
end
|
||||
|
||||
def pack_arch
|
||||
builder_config["pack"]["arch"] if pack?
|
||||
end
|
||||
|
||||
def pack_builder
|
||||
builder_config["pack"]["builder"] if pack?
|
||||
end
|
||||
|
||||
def pack_buildpacks
|
||||
builder_config["pack"]["buildpacks"] if pack?
|
||||
end
|
||||
|
||||
def remote_arch
|
||||
builder_config["remote"]["arch"] if remote?
|
||||
end
|
||||
|
||||
@@ -37,6 +37,16 @@ builder:
|
||||
arch: arm64
|
||||
host: ssh://docker@docker-builder
|
||||
|
||||
# Buildpack configuration
|
||||
#
|
||||
# The build configuration for using pack to build a Cloud Native Buildpack image.
|
||||
pack:
|
||||
builder: heroku/builder:24
|
||||
arch: amd64
|
||||
buildpacks:
|
||||
- heroku/ruby
|
||||
- heroku/procfile
|
||||
|
||||
# Builder cache
|
||||
#
|
||||
# The type must be either 'gha' or 'registry'
|
||||
|
||||
Reference in New Issue
Block a user