-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pack option to the builder options for cloud native buildpacks #916
base: main
Are you sure you want to change the base?
Changes from all commits
897b3b4
826308a
d0ffb85
24f4308
ae68193
2c5f2a7
548452a
85a5a09
e252004
7174174
f7147e0
c601241
dda8efe
5482052
89b4415
1d55c59
4822a9d
d538447
145b73c
1ebc8b8
cde5c7a
8354fbe
9ac3d57
9f6660d
d249b9a
95b606a
da26457
f8f7c6e
8c17b1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class Kamal::Commands::Builder::Pack < Kamal::Commands::Builder::Base | ||
def push(export_action = "registry") | ||
combine \ | ||
build, | ||
export(export_action) | ||
end | ||
|
||
def remove;end | ||
|
||
def info | ||
pack :builder, :inspect, pack_builder | ||
end | ||
alias_method :inspect_builder, :info | ||
|
||
private | ||
def build | ||
pack(:build, | ||
config.repository, | ||
"--platform", platform, | ||
"--creation-time", "now", | ||
"--builder", pack_builder, | ||
buildpacks, | ||
"-t", config.absolute_image, | ||
"-t", config.latest_image, | ||
"--env", "BP_IMAGE_LABELS=service=#{config.service}", | ||
*argumentize("--env", args), | ||
*argumentize("--env", secrets, sensitive: true), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is using environment variables the standard way to get secrets into a buildpack? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @djmb Yes, they only have the I just tested building with a few secrets because I was concerned they'd end up in the final image but they don't. I just found this in the docs site though. TLDR; It's just a build-time env var, they're not available at image runtime. So they're naturally "secret", neat. https://buildpacks.io/docs/for-platform-operators/how-to/integrate-ci/pack/cli/pack_build/#options
|
||
"--path", build_context) | ||
end | ||
|
||
def export(export_action) | ||
return unless export_action == "registry" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the output option changes from #1357, support needed to be added for an export_action but it's a little different than docker buildx output behavior. I went with supporting a build and push behavior as the default and then if you specify anything other than registry it just doesn't push the image to the registry. I don't believe there's additional options for the output format since pack build is just outputting the OCI image but @edmorley might have some ideas here. Docker buildx output options: https://docs.docker.com/reference/cli/docker/buildx/build/#output There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi! I'm not sure I quite follow the question (I've only skimmed the comments via email notifications) - but in case it helps, this is the only Pack CLI option relating to how the generated asset is handled:
|
||
|
||
combine \ | ||
docker(:push, config.absolute_image), | ||
docker(:push, config.latest_image) | ||
end | ||
|
||
def platform | ||
"linux/#{local_arches.first}" | ||
nickhammond marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
||
def buildpacks | ||
(pack_buildpacks << "paketo-buildpacks/image-labels").map { |buildpack| [ "--buildpack", buildpack ] } | ||
nickhammond marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
# | ||
# Options go under the builder key in the root configuration. | ||
builder: | ||
|
||
# Arch | ||
# | ||
# The architectures to build for — you can set an array or just a single value. | ||
|
@@ -31,6 +30,19 @@ builder: | |
# Defaults to true: | ||
local: true | ||
|
||
# Buildpack configuration | ||
# | ||
# The build configuration for using pack to build a Cloud Native Buildpack image. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add mention of project.toml to set your excluded options. https://buildpacks.io/docs/for-app-developers/how-to/build-inputs/use-project-toml/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I was thinking about this and removing |
||
# | ||
# For additional buildpack customization options you can create a project descriptor | ||
# file(project.toml) that the Pack CLI will automatically use. | ||
# See https://buildpacks.io/docs/for-app-developers/how-to/build-inputs/use-project-toml/ for more information. | ||
pack: | ||
builder: heroku/builder:24 | ||
buildpacks: | ||
- heroku/ruby | ||
- heroku/procfile | ||
|
||
# Builder cache | ||
# | ||
# The type must be either 'gha' or 'registry'. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With docker, build args are passed as
--build-arg
and with Kamal you set them via:You'd still set "build args" with pack via the same
args
section but they ultimately get passed as--env
to the pack command. Trying to reduce confusion of when to use env/arg if you're testing out your builds.