-
Notifications
You must be signed in to change notification settings - Fork 455
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 14 commits
897b3b4
826308a
d0ffb85
24f4308
ae68193
2c5f2a7
548452a
85a5a09
e252004
7174174
f7147e0
c601241
dda8efe
5482052
89b4415
1d55c59
4822a9d
d538447
145b73c
1ebc8b8
cde5c7a
8354fbe
9ac3d57
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,26 @@ | ||
class Kamal::Commands::Builder::Pack < Kamal::Commands::Builder::Base | ||
def push | ||
combine \ | ||
pack(:build, | ||
config.repository, | ||
"--platform", platform, | ||
"--builder", pack_builder, | ||
buildpacks, | ||
"-t", config.absolute_image, | ||
"-t", config.latest_image, | ||
"--env", "BP_IMAGE_LABELS=service=#{config.service}", | ||
*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), | ||
docker(:push, config.absolute_image), | ||
docker(:push, config.latest_image) | ||
end | ||
|
||
private | ||
def platform | ||
"linux/#{local_arches.first}" | ||
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. Pack only supports building for one platform, make it obvious in docs 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. We can add a validation for this in 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 Added a validation for this. |
||
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.
Maybe we could extract a
buildx?
method here?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.
@djmb We could also run
pack builder inspect
which returns a bunch of information about the default builder. It's a lot of information but might be useful to help triage if you're not sure what builder you're using. The Pack CLI lets you set your default builder so I have mine set toheroku/builder:24
viapack config default-builder heroku/builder:24
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.
@nickhammond Does this mean I can now pass my builder name to kamal?
Buildx cloud_builder
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.
@alexohre No, I don't think there's a PR open for that, just the discussion here #914 (comment)