-
Notifications
You must be signed in to change notification settings - Fork 458
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
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,35 @@ | ||
class Kamal::Commands::Builder::Pack < Kamal::Commands::Builder::Base | ||
def push | ||
combine \ | ||
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), | ||
docker(:push, config.absolute_image), | ||
docker(:push, config.latest_image) | ||
end | ||
|
||
def remove;end | ||
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're not actually creating anything with the buildpack setup so there isn't anything to remove. Should we still |
||
|
||
def info | ||
pack :builder, :inspect, pack_builder | ||
end | ||
alias_method :inspect_builder, :info | ||
|
||
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.
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.