-
Notifications
You must be signed in to change notification settings - Fork 286
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 a custom lifecycle image flag #1088
Conversation
a3a2188
to
64d5868
Compare
Codecov Report
@@ Coverage Diff @@
## main #1088 +/- ##
==========================================
+ Coverage 80.40% 80.56% +0.17%
==========================================
Files 130 131 +1
Lines 7983 8050 +67
==========================================
+ Hits 6418 6485 +67
Misses 1147 1147
Partials 418 418
Flags with carried forward coverage won't be shown. Click here to find out more. |
a042662
to
36c6124
Compare
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.
Overall this feature implementation looks great! Thank you.
As for acceptance tests, given the level of testing at the unit level and risk factor, I wouldn't hold this PR on acceptance test. That said, if you wanted to put in the effort I can foresee something similar to this test but with a temporary lifecycle image created as part of the Before
step.
build.go
Outdated
lifecycleImage, err := c.imageFetcher.Fetch( | ||
ctx, | ||
fmt.Sprintf("%s:%s", LifecycleImageRepo, lifecycleVersion.String()), | ||
fmt.Sprintf("%s:%s", lifecycleImageRepo, lifecycleVersion.String()), |
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.
I'm curious how this feature of setting a specific lifecycle repo plays with specific images and lifecycle versions.
For example, say I have a very specific SHA I wanted to test myorg/mylifecycle@sha256:...
or say I wanted to run an image that is tagged differently myorg/mylifecycle:tomato
(because I like naming stuff :)).
Given the current simple appending strategy it would appear that the above cases would not be supported. I wonder if we can easily enable them by parsing the input to determine if a Digest
or Tag
was provided.
In my mind it would look something like:
input | builder lifecycle version | image used |
---|---|---|
myorg/lifecycle | 0.10.2 | myorg/lifecycle:0.10.2 |
myorg/lifecycle@sha256:123... | 0.10.2 | myorg/lifecycle@sha256:123... |
myorg/lifecycle:tomato | 0.10.2 | myorg/lifecycle:tomato |
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.
The reason I didn't enable this was because it might cause conflicts with the builder's lifecycle version. Would we be saying that we will be overriding the lifecycle version set by the builder.toml in favor of this lifecycle image? And how would we handle compat issues?
As such, I thought that at first supporting just a different repo/registry (which may be an internal mirror) would be the easiest. I think there were some suggestions about moving away from a hardcoded lifecycle version to the supported platform version instead (see #904) in which case I think we can relax the constraints and provide some better handling here.
This may be out of the scope of this PR/issue given that the original issue was just to support mirrors, but if it is just an easy hardcoded override as you suggested above, I can add that in this PR (or a follow up one).
Let me know what you think :)
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.
I don't think the lifecycle version disparity between phases is a huge concern given that it's a contract (Platform API) that is being adhered to. For example, this hardcoded version in tekton could be different than that provided by the builder.
@ekcasey / @natalieparellano correct me if I'm wrong.
Furthermore, I would suspect that the use of this option is an "advanced" option meaning that the user would have more of an idea on what ramifications may be by forcing a specific lifecycle image.
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.
Gotcha - so the expected changes is as you described in the table above -
If the user gives just the image repo - we use the lifecycle version as the tag. If they specify a image repo + tag we use that. Same for image repo + SHAs?
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.
Just my two cents but I think we should interpret --lifecycle-image myorg/lifecycle
as --lifecycle-image myorg/lifecycle:latest
. Folks are very used to the implicit :latest
and doing anything else might be surprising.
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.
Hmm - makes sense. Should I rename the flag from image repo to image/image tag then?
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.
--lifecycle-image
makes the most sense to me
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.
Just my two cents but I think we should interpret
--lifecycle-image myorg/lifecycle
as--lifecycle-image myorg/lifecycle:latest
. Folks are very used to the implicit:latest
and doing anything else might be surprising.
I'd be in favor of that due to the positive UX. I was more concerned with appending lifecycle versions tags. If that's no longer the case then my suggestions above are moot.
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.
In general probably we'd want to recommend using the same lifecycle version as the provided builder (if possible) but as long as the lifecycle supports the same api versions as the builder, it should work.
4e3835e
to
8330616
Compare
8330616
to
96e98c6
Compare
Updated to use |
96e98c6
to
0bd6e33
Compare
There is potentially some additional complexity to considering regarding the platform API. I assume we currently use the latest platform API support by both the builder and pack. Now we should probably choose the latest platform API support by all three components (builder, pack, lifecycle image). Thoughts @dfreilich @jromero ? |
That's a really good point. That sounds like a great idea. @samj1912 I would recommend that we maintain scope and create a separate issue (feature) and thereby PR with @ekcasey's suggestion. |
That makes sense, is this PR ready for merging then? |
does this issue capture the above discussion #1091? Please feel free to make edits if I misunderstood something. |
internal/commands/build.go
Outdated
@@ -151,6 +162,7 @@ If not set (or set to empty string) the standard socket location will be used. | |||
Special value 'inherit' may be used in which case DOCKER_HOST environment variable will be used. | |||
This option may set DOCKER_HOST environment variable for the build container if needed. | |||
`) | |||
cmd.Flags().StringVar(&buildFlags.LifecycleImage, "lifecycle-image", cfg.LifecycleImage, `Custom lifecycle image to use. If not provided a lifecycle image from "buildpacksio/lifecycle" will be used.`) |
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.
cmd.Flags().StringVar(&buildFlags.LifecycleImage, "lifecycle-image", cfg.LifecycleImage, `Custom lifecycle image to use. If not provided a lifecycle image from "buildpacksio/lifecycle" will be used.`) | |
cmd.Flags().StringVar(&buildFlags.LifecycleImage, "lifecycle-image", cfg.LifecycleImage, `Custom lifecycle image to use for analysis, restore, and export when builder is untrusted. If not provided a lifecycle image from "buildpacksio/lifecycle" will be used.`) |
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.
IDK if this is too verbose... I was just trying to get the point across that it's not used ALL the time.
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.
I used "The image to use when executing sensitive phases." on the Tekton task. Not sure it's much better. 🤦♂️
h.AssertNil(t, command.Execute()) | ||
}) | ||
}) | ||
when("a custom image repo is provided with a tag", func() { |
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.
This is going to be so helpful in validating pre-release versions of the lifecycle!
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.
⚠️ Acceptance
Overall this feature works like a charm! There is a minor confusing bit on the flag description and how "default" is represented. I've added more details below. Let me know if you have any questions.
✅ pack config
❯ pack-dev config
Interact with your local pack config file
Usage:
pack config [command]
Available Commands:
default-builder List, set and unset the default builder used by other commands
experimental List and set the current 'experimental' value from the config
pull-policy List, set and unset the global pull policy used by other commands
registries List, add and remove registries
run-image-mirrors List, add and remove run image mirrors
trusted-builders List, add and remove trusted builders
lifecycle-image Configure a custom container image for the lifecycle
Flags:
-h, --help Help for 'config'
Global Flags:
--no-color Disable color output
-q, --quiet Show less output
--timestamps Enable timestamps in output
-v, --verbose Show more output
Use "pack config [command] --help" for more information about a command.
❯ pack-dev config lifecycle-image --help
You can use this command to set a custom image to fetch the lifecycle from.This will be used for untrusted builders. If unset, defaults to: buildpacksio/lifecycleFor more on trusted builders, and when to trust or untrust a builder, check out our docs here: https://buildpacks.io/docs/tools/pack/concepts/trusted_builders/
Usage:
pack config lifecycle-image <lifecycle-image> [flags]
Flags:
-h, --help Help for 'lifecycle-image'
-u, --unset Unset custom lifecycle image, and use the lifecycle images from buildpacksio/lifecycle
Global Flags:
--no-color Disable color output
-q, --quiet Show less output
--timestamps Enable timestamps in output
-v, --verbose Show more output
❯ pack-dev config lifecycle-image buildpacksio/lifecycle:0.10.1
Image buildpacksio/lifecycle:0.10.1 will now be used as the lifecycle image
❯ pack-dev config lifecycle-image --unset
Successfully unset custom lifecycle image buildpacksio/lifecycle:0.10.1
✅ pack build --lifecycle-image ...
❯ pack-dev config lifecycle-image
No custom lifecycle image is set. Lifecycle images from buildpacksio/lifecycle repo will be used.
pack on custom-lifecycle via 🐹 v1.16 on ☁️ rjavier@vmware.com
❯ pack-dev build my-app -B cnbs/sample-builder:bionic -p ../samples/apps/bash-script/ -v --lifecycle-image buildpacksio/lifecycle:0.10.0
Using project descriptor located at ../samples/apps/bash-script/project.toml
Builder cnbs/sample-builder:bionic is untrusted
As a result, the phases of the lifecycle which require root access will be run in separate trusted ephemeral containers.
For more information, see https://medium.com/buildpacks/faster-more-secure-builds-with-pack-0-11-0-4d0c633ca619
Pulling image index.docker.io/cnbs/sample-builder:bionic
bionic: Pulling from cnbs/sample-builder
Digest: sha256:6c03dd604503b59820fd15adbc65c0a077a47e31d404a3dcad190f3179e920b5
Status: Image is up to date for cnbs/sample-builder:bionic
Selected run image cnbs/sample-stack-run:bionic
Pulling image cnbs/sample-stack-run:bionic
bionic: Pulling from cnbs/sample-stack-run
Digest: sha256:766617895a96c9cdc58fa604468328f6918a13f5c225fbe267b37df9dce40fda
Status: Image is up to date for cnbs/sample-stack-run:bionic
Downloading buildpack from URI: file:///Users/jromero/dev/buildpacks/samples/apps/bash-script/bash-script-buildpack
Adding buildpack samples/bash-script version 0.0.1 to builder
Setting custom order
Creating builder with the following buildpacks:
-> samples/java-maven@0.0.1
-> samples/kotlin-gradle@0.0.1
-> samples/ruby-bundler@0.0.1
-> samples/hello-universe@0.0.1
-> samples/hello-moon@0.0.1
-> samples/hello-world@0.0.1
-> samples/bash-script@0.0.1
Pulling image index.docker.io/buildpacksio/lifecycle:0.10.0
0.10.0: Pulling from buildpacksio/lifecycle
e59bd8947ac7: Already exists
3f7b1ee07092: Pull complete
Digest: sha256:33659bf8db9908942088aa8edefb9a4193017dba518648ee5fd3b87b3515c4ba
Status: Downloaded newer image for buildpacksio/lifecycle:0.10.0
Using build cache volume pack-cache-library_my-app_latest-cbd6ecf04229.build
===> DETECTING
Running the detector on OS linux with:
Container Settings:
Args: /cnb/lifecycle/detector -log-level debug
System Envs: CNB_PLATFORM_API=0.4
Image: pack.local/builder/6d6a7a65726a74677066:latest
User:
Labels: map[author:pack]
Host Settings:
Binds: pack-layers-nwqvcdagaa:/layers pack-app-qawcuzdmtv:/workspace
Network Mode:
[detector] ======== Output: samples/bash-script@0.0.1 ========
[detector] ---> Hello Bash Script buildpack
[detector]
[detector] Here are the contents of the current working directory:
[detector] .:
[detector] total 16
[detector] drwxr-xr-x 2 cnb cnb 4096 Feb 26 15:48 .
[detector] drwxr-xr-x 1 root root 4096 Feb 26 15:48 ..
[detector] -rwxr-xr-x 1 cnb cnb 736 Nov 13 18:43 app.sh
[detector] -rw-r--r-- 1 cnb cnb 202 Dec 7 21:15 project.toml
[detector] ======== Results ========
[detector] pass: samples/bash-script@0.0.1
[detector] Resolving plan... (try #1)
[detector] samples/bash-script 0.0.1
===> ANALYZING
Running the analyzer on OS linux with:
Container Settings:
Args: /cnb/lifecycle/analyzer -log-level debug -daemon -cache-dir /cache my-app
System Envs: CNB_USER_ID=1000 CNB_GROUP_ID=1000 CNB_PLATFORM_API=0.4
Image: index.docker.io/buildpacksio/lifecycle:0.10.0
User: root
Labels: map[author:pack]
Host Settings:
Binds: /var/run/docker.sock:/var/run/docker.sock pack-cache-library_my-app_latest-cbd6ecf04229.build:/cache pack-layers-nwqvcdagaa:/layers pack-app-qawcuzdmtv:/workspace
Network Mode:
[analyzer] Analyzing image "1ae65fdd25cfddab29f43676c98f626a26b77cda4d1c85468634b8498cf20b40"
===> RESTORING
Running the restorer on OS linux with:
Container Settings:
Args: /cnb/lifecycle/restorer -log-level debug -cache-dir /cache
System Envs: CNB_USER_ID=1000 CNB_GROUP_ID=1000 CNB_PLATFORM_API=0.4
Image: index.docker.io/buildpacksio/lifecycle:0.10.0
User: root
Labels: map[author:pack]
Host Settings:
Binds: pack-cache-library_my-app_latest-cbd6ecf04229.build:/cache pack-layers-nwqvcdagaa:/layers pack-app-qawcuzdmtv:/workspace
Network Mode:
===> BUILDING
Running the builder on OS linux with:
Container Settings:
Args: /cnb/lifecycle/builder -log-level debug
System Envs: CNB_PLATFORM_API=0.4
Image: pack.local/builder/6d6a7a65726a74677066:latest
User:
Labels: map[author:pack]
Host Settings:
Binds: pack-layers-nwqvcdagaa:/layers pack-app-qawcuzdmtv:/workspace
Network Mode:
[builder] ---> Bash Script buildpack
[builder]
[builder] Here are the contents of the current working directory:
[builder] .:
[builder] total 16
[builder] drwxr-xr-x 2 cnb cnb 4096 Feb 26 15:48 .
[builder] drwxr-xr-x 1 root root 4096 Feb 26 15:48 ..
[builder] -rwxr-xr-x 1 cnb cnb 736 Nov 13 18:43 app.sh
[builder] -rw-r--r-- 1 cnb cnb 202 Dec 7 21:15 project.toml
===> EXPORTING
Running the exporter on OS linux with:
Container Settings:
Args: /cnb/lifecycle/exporter -daemon -launch-cache /launch-cache -log-level debug -cache-dir /cache -stack /layers/stack.toml -run-image cnbs/sample-stack-run:bionic -process-type web my-app
System Envs: CNB_USER_ID=1000 CNB_GROUP_ID=1000 CNB_PLATFORM_API=0.4
Image: index.docker.io/buildpacksio/lifecycle:0.10.0
User: root
Labels: map[author:pack]
Host Settings:
Binds: pack-cache-library_my-app_latest-cbd6ecf04229.build:/cache /var/run/docker.sock:/var/run/docker.sock pack-cache-library_my-app_latest-cbd6ecf04229.launch:/launch-cache pack-layers-nwqvcdagaa:/layers pack-app-qawcuzdmtv:/workspace
Network Mode:
[exporter] no project metadata found at path 'project-metadata.toml', project metadata will not be exported
[exporter] Reusing layers from image with id '1ae65fdd25cfddab29f43676c98f626a26b77cda4d1c85468634b8498cf20b40'
[exporter] Layer 'slice-1' SHA: sha256:cb8b3af9dce9dd8a9dede65150a33b9f1f18ed40299d21c171f1602906fbf547
[exporter] Reusing 1/1 app layer(s)
[exporter] Reusing tarball for layer "launcher" with SHA: sha256:77759bcd65acbe1ddc8b6f4530cd15368378a9f993a51e6b28deaac08a83c8c3
[exporter] Adding layer 'launcher'
[exporter] Layer 'launcher' SHA: sha256:77759bcd65acbe1ddc8b6f4530cd15368378a9f993a51e6b28deaac08a83c8c3
[exporter] Reusing tarball for layer "config" with SHA: sha256:9379d5b2aae4ee862336e787f0702ad03d98ed4b564c3106e70d6a290fcd9a43
[exporter] Reusing layer 'config'
[exporter] Layer 'config' SHA: sha256:9379d5b2aae4ee862336e787f0702ad03d98ed4b564c3106e70d6a290fcd9a43
[exporter] Reusing tarball for layer "process-types" with SHA: sha256:83d85471d9f8a3834b4e27cf701e3f0aef220cc816d9c173c7d32cd73909a590
[exporter] Reusing layer 'process-types'
[exporter] Layer 'process-types' SHA: sha256:83d85471d9f8a3834b4e27cf701e3f0aef220cc816d9c173c7d32cd73909a590
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] Setting CNB_LAYERS_DIR=/layers
[exporter] Setting CNB_APP_DIR=/workspace
[exporter] Setting CNB_PLATFORM_API=0.4
[exporter] Setting CNB_DEPRECATION_MODE=quiet
[exporter] Prepending /cnb/process and /cnb/lifecycle to PATH
[exporter] Setting default process type 'web'
[exporter] Setting ENTRYPOINT: '/cnb/process/web'
[exporter] *** Images (1be00e206e64):
[exporter] my-app
[exporter]
[exporter] *** Image ID: 1be00e206e64a282d18682a3b22ff8a440b6916f2f197b8fac74366d1a38a957
Successfully built image my-app
pack on custom-lifecycle via 🐹 v1.16 on ☁️ rjavier@vmware.com took 12s
❯ pack-dev config lifecycle-image buildpacksio/lifecycle:0.10.1
Image buildpacksio/lifecycle:0.10.1 will now be used as the lifecycle image
pack on custom-lifecycle via 🐹 v1.16 on ☁️ rjavier@vmware.com
❯ pack-dev build my-app -B cnbs/sample-builder:bionic -p ../samples/apps/bash-script/ -v --lifecycle-image buildpacksio/lifecycle:0.10.0
Using project descriptor located at ../samples/apps/bash-script/project.toml
Builder cnbs/sample-builder:bionic is untrusted
As a result, the phases of the lifecycle which require root access will be run in separate trusted ephemeral containers.
For more information, see https://medium.com/buildpacks/faster-more-secure-builds-with-pack-0-11-0-4d0c633ca619
Pulling image index.docker.io/cnbs/sample-builder:bionic
bionic: Pulling from cnbs/sample-builder
Digest: sha256:6c03dd604503b59820fd15adbc65c0a077a47e31d404a3dcad190f3179e920b5
Status: Image is up to date for cnbs/sample-builder:bionic
Selected run image cnbs/sample-stack-run:bionic
Pulling image cnbs/sample-stack-run:bionic
bionic: Pulling from cnbs/sample-stack-run
Digest: sha256:766617895a96c9cdc58fa604468328f6918a13f5c225fbe267b37df9dce40fda
Status: Image is up to date for cnbs/sample-stack-run:bionic
Downloading buildpack from URI: file:///Users/jromero/dev/buildpacks/samples/apps/bash-script/bash-script-buildpack
Adding buildpack samples/bash-script version 0.0.1 to builder
Setting custom order
Creating builder with the following buildpacks:
-> samples/java-maven@0.0.1
-> samples/kotlin-gradle@0.0.1
-> samples/ruby-bundler@0.0.1
-> samples/hello-universe@0.0.1
-> samples/hello-moon@0.0.1
-> samples/hello-world@0.0.1
-> samples/bash-script@0.0.1
Pulling image index.docker.io/buildpacksio/lifecycle:0.10.0
0.10.0: Pulling from buildpacksio/lifecycle
Digest: sha256:33659bf8db9908942088aa8edefb9a4193017dba518648ee5fd3b87b3515c4ba
Status: Image is up to date for buildpacksio/lifecycle:0.10.0
Using build cache volume pack-cache-library_my-app_latest-cbd6ecf04229.build
===> DETECTING
Running the detector on OS linux with:
Container Settings:
Args: /cnb/lifecycle/detector -log-level debug
System Envs: CNB_PLATFORM_API=0.4
Image: pack.local/builder/786762616779646f7362:latest
User:
Labels: map[author:pack]
Host Settings:
Binds: pack-layers-vdskapvreh:/layers pack-app-okgazsmoud:/workspace
Network Mode:
[detector] ======== Output: samples/bash-script@0.0.1 ========
[detector] ---> Hello Bash Script buildpack
[detector]
[detector] Here are the contents of the current working directory:
[detector] .:
[detector] total 16
[detector] drwxr-xr-x 2 cnb cnb 4096 Feb 26 15:48 .
[detector] drwxr-xr-x 1 root root 4096 Feb 26 15:48 ..
[detector] -rwxr-xr-x 1 cnb cnb 736 Nov 13 18:43 app.sh
[detector] -rw-r--r-- 1 cnb cnb 202 Dec 7 21:15 project.toml
[detector] ======== Results ========
[detector] pass: samples/bash-script@0.0.1
[detector] Resolving plan... (try #1)
[detector] samples/bash-script 0.0.1
===> ANALYZING
Running the analyzer on OS linux with:
Container Settings:
Args: /cnb/lifecycle/analyzer -log-level debug -daemon -cache-dir /cache my-app
System Envs: CNB_USER_ID=1000 CNB_GROUP_ID=1000 CNB_PLATFORM_API=0.4
Image: index.docker.io/buildpacksio/lifecycle:0.10.0
User: root
Labels: map[author:pack]
Host Settings:
Binds: /var/run/docker.sock:/var/run/docker.sock pack-cache-library_my-app_latest-cbd6ecf04229.build:/cache pack-layers-vdskapvreh:/layers pack-app-okgazsmoud:/workspace
Network Mode:
[analyzer] Analyzing image "1be00e206e64a282d18682a3b22ff8a440b6916f2f197b8fac74366d1a38a957"
===> RESTORING
Running the restorer on OS linux with:
Container Settings:
Args: /cnb/lifecycle/restorer -log-level debug -cache-dir /cache
System Envs: CNB_USER_ID=1000 CNB_GROUP_ID=1000 CNB_PLATFORM_API=0.4
Image: index.docker.io/buildpacksio/lifecycle:0.10.0
User: root
Labels: map[author:pack]
Host Settings:
Binds: pack-cache-library_my-app_latest-cbd6ecf04229.build:/cache pack-layers-vdskapvreh:/layers pack-app-okgazsmoud:/workspace
Network Mode:
===> BUILDING
Running the builder on OS linux with:
Container Settings:
Args: /cnb/lifecycle/builder -log-level debug
System Envs: CNB_PLATFORM_API=0.4
Image: pack.local/builder/786762616779646f7362:latest
User:
Labels: map[author:pack]
Host Settings:
Binds: pack-layers-vdskapvreh:/layers pack-app-okgazsmoud:/workspace
Network Mode:
[builder] ---> Bash Script buildpack
[builder]
[builder] Here are the contents of the current working directory:
[builder] .:
[builder] total 16
[builder] drwxr-xr-x 2 cnb cnb 4096 Feb 26 15:48 .
[builder] drwxr-xr-x 1 root root 4096 Feb 26 15:48 ..
[builder] -rwxr-xr-x 1 cnb cnb 736 Nov 13 18:43 app.sh
[builder] -rw-r--r-- 1 cnb cnb 202 Dec 7 21:15 project.toml
===> EXPORTING
Running the exporter on OS linux with:
Container Settings:
Args: /cnb/lifecycle/exporter -daemon -launch-cache /launch-cache -log-level debug -cache-dir /cache -stack /layers/stack.toml -run-image cnbs/sample-stack-run:bionic -process-type web my-app
System Envs: CNB_USER_ID=1000 CNB_GROUP_ID=1000 CNB_PLATFORM_API=0.4
Image: index.docker.io/buildpacksio/lifecycle:0.10.0
User: root
Labels: map[author:pack]
Host Settings:
Binds: pack-cache-library_my-app_latest-cbd6ecf04229.build:/cache /var/run/docker.sock:/var/run/docker.sock pack-cache-library_my-app_latest-cbd6ecf04229.launch:/launch-cache pack-layers-vdskapvreh:/layers pack-app-okgazsmoud:/workspace
Network Mode:
[exporter] no project metadata found at path 'project-metadata.toml', project metadata will not be exported
[exporter] Reusing layers from image with id '1be00e206e64a282d18682a3b22ff8a440b6916f2f197b8fac74366d1a38a957'
[exporter] Layer 'slice-1' SHA: sha256:cb8b3af9dce9dd8a9dede65150a33b9f1f18ed40299d21c171f1602906fbf547
[exporter] Reusing 1/1 app layer(s)
[exporter] Reusing tarball for layer "launcher" with SHA: sha256:77759bcd65acbe1ddc8b6f4530cd15368378a9f993a51e6b28deaac08a83c8c3
[exporter] Reusing layer 'launcher'
[exporter] Layer 'launcher' SHA: sha256:77759bcd65acbe1ddc8b6f4530cd15368378a9f993a51e6b28deaac08a83c8c3
[exporter] Reusing tarball for layer "config" with SHA: sha256:9379d5b2aae4ee862336e787f0702ad03d98ed4b564c3106e70d6a290fcd9a43
[exporter] Reusing layer 'config'
[exporter] Layer 'config' SHA: sha256:9379d5b2aae4ee862336e787f0702ad03d98ed4b564c3106e70d6a290fcd9a43
[exporter] Reusing tarball for layer "process-types" with SHA: sha256:83d85471d9f8a3834b4e27cf701e3f0aef220cc816d9c173c7d32cd73909a590
[exporter] Reusing layer 'process-types'
[exporter] Layer 'process-types' SHA: sha256:83d85471d9f8a3834b4e27cf701e3f0aef220cc816d9c173c7d32cd73909a590
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] Setting CNB_LAYERS_DIR=/layers
[exporter] Setting CNB_APP_DIR=/workspace
[exporter] Setting CNB_PLATFORM_API=0.4
[exporter] Setting CNB_DEPRECATION_MODE=quiet
[exporter] Prepending /cnb/process and /cnb/lifecycle to PATH
[exporter] Setting default process type 'web'
[exporter] Setting ENTRYPOINT: '/cnb/process/web'
[exporter] *** Images (1be00e206e64):
[exporter] my-app
[exporter]
[exporter] *** Image ID: 1be00e206e64a282d18682a3b22ff8a440b6916f2f197b8fac74366d1a38a957
Successfully built image my-app
⚠️ pack build --help ...
Flag description
When a lifecycle image is configured via pack config
the flag description is a little confusing.
Custom lifecycle image to use. If not provided a lifecycle image from "buildpacksio/lifecycle" will be used. (default "buildpacksio/lifecycle:0.10.1")
I would have expected something like:
Custom lifecycle image to use. (default "buildpacksio/lifecycle:0.10.1")
And furthermore when a lifecycle image is not configured, something like:
Custom lifecycle image to use. (default "buildpacksio/lifecycle")
Full output:
❯ pack-dev build --help
Pack Build uses Cloud Native Buildpacks to create a runnable app image from source code.
Pack Build requires an image name, which will be generated from the source code. Build defaults to the current directory, but you can use `--path` to specify another source code directory. Build requires a `builder`, which can either be provided directly to build using `--builder`, or can be set using the `set-default-builder` command. For more on how to use `pack build`, see: https://buildpacks.io/docs/app-developer-guide/build-an-app/.
Usage:
pack build <image-name> [flags]
Examples:
pack build test_img --path apps/test-app --builder cnbs/sample-builder:bionic
Flags:
-B, --builder string Builder image
-b, --buildpack strings Buildpack to use. One of:
a buildpack by id and version in the form of '<buildpack>@<version>',
path to a buildpack directory (not supported on Windows),
path/URL to a buildpack .tar or .tgz file, or
a packaged buildpack image name in the form of '<hostname>/<repo>[:<tag>]'
Repeat for each buildpack in order, or supply once by comma-separated list
-r, --buildpack-registry string Buildpack Registry by name
--cache-image string Cache build layers in remote registry. Requires --publish
--clear-cache Clear image's associated cache before building
-D, --default-process string Set the default process type. (default "web")
-d, --descriptor string Path to the project descriptor file
--docker-host string Address to docker daemon that will be exposed to the build container.
If not set (or set to empty string) the standard socket location will be used.
Special value 'inherit' may be used in which case DOCKER_HOST environment variable will be used.
This option may set DOCKER_HOST environment variable for the build container if needed.
-e, --env stringArray Build-time environment variable, in the form 'VAR=VALUE' or 'VAR'.
When using latter value-less form, value will be taken from current
environment at the time this command is executed.
This flag may be specified multiple times and will override
individual values defined by --env-file.
Repeat for each env in order, or supply once by comma-separated list
NOTE: These are NOT available at image runtime.
--env-file stringArray Build-time environment variables file
One variable per line, of the form 'VAR=VALUE' or 'VAR'
When using latter value-less form, value will be taken from current
environment at the time this command is executed
NOTE: These are NOT available at image runtime."
-h, --help Help for 'build'
--lifecycle-image string Custom lifecycle image to use. If not provided a lifecycle image from "buildpacksio/lifecycle" will be used. (default "buildpacksio/lifecycle:0.10.1")
--network string Connect detect and build containers to network
-p, --path string Path to app dir or zip-formatted file (defaults to current working directory)
--publish Publish to registry
--pull-policy string Pull policy to use. Accepted values are always, never, and if-not-present. (default "always")
--run-image string Run image (defaults to default stack's run image)
-t, --tag strings Additional tags to push the output image to.
Repeat for each tag in order, or supply once by comma-separated list
--trust-builder Trust the provided builder
All lifecycle phases will be run in a single container (if supported by the lifecycle).
--volume stringArray Mount host volume into the build container, in the form '<host path>:<target path>[:<options>]'.
- 'host path': Name of the volume or absolute directory path to mount.
- 'target path': The path where the file or directory is available in the container.
- 'options' (default "ro"): An optional comma separated list of mount options.
- "ro", volume contents are read-only.
- "rw", volume contents are readable and writeable.
- "volume-opt=<key>=<value>", can be specified more than once, takes a key-value pair consisting of the option name and its value.
Repeat for each volume in order, or supply once by comma-separated list
Global Flags:
--no-color Disable color output
-q, --quiet Show less output
--timestamps Enable timestamps in output
-v, --verbose Show more output
pack on custom-lifecycle via 🐹 v1.16 on ☁️ rjavier@vmware.com
❯ pack-dev config lifecycle-image --unset
Successfully unset custom lifecycle image buildpacksio/lifecycle:0.10.1
pack on custom-lifecycle via 🐹 v1.16 on ☁️ rjavier@vmware.com
❯ pack-dev build --help
Pack Build uses Cloud Native Buildpacks to create a runnable app image from source code.
Pack Build requires an image name, which will be generated from the source code. Build defaults to the current directory, but you can use `--path` to specify another source code directory. Build requires a `builder`, which can either be provided directly to build using `--builder`, or can be set using the `set-default-builder` command. For more on how to use `pack build`, see: https://buildpacks.io/docs/app-developer-guide/build-an-app/.
Usage:
pack build <image-name> [flags]
Examples:
pack build test_img --path apps/test-app --builder cnbs/sample-builder:bionic
Flags:
-B, --builder string Builder image
-b, --buildpack strings Buildpack to use. One of:
a buildpack by id and version in the form of '<buildpack>@<version>',
path to a buildpack directory (not supported on Windows),
path/URL to a buildpack .tar or .tgz file, or
a packaged buildpack image name in the form of '<hostname>/<repo>[:<tag>]'
Repeat for each buildpack in order, or supply once by comma-separated list
-r, --buildpack-registry string Buildpack Registry by name
--cache-image string Cache build layers in remote registry. Requires --publish
--clear-cache Clear image's associated cache before building
-D, --default-process string Set the default process type. (default "web")
-d, --descriptor string Path to the project descriptor file
--docker-host string Address to docker daemon that will be exposed to the build container.
If not set (or set to empty string) the standard socket location will be used.
Special value 'inherit' may be used in which case DOCKER_HOST environment variable will be used.
This option may set DOCKER_HOST environment variable for the build container if needed.
-e, --env stringArray Build-time environment variable, in the form 'VAR=VALUE' or 'VAR'.
When using latter value-less form, value will be taken from current
environment at the time this command is executed.
This flag may be specified multiple times and will override
individual values defined by --env-file.
Repeat for each env in order, or supply once by comma-separated list
NOTE: These are NOT available at image runtime.
--env-file stringArray Build-time environment variables file
One variable per line, of the form 'VAR=VALUE' or 'VAR'
When using latter value-less form, value will be taken from current
environment at the time this command is executed
NOTE: These are NOT available at image runtime."
-h, --help Help for 'build'
--lifecycle-image string Custom lifecycle image to use. If not provided a lifecycle image from "buildpacksio/lifecycle" will be used.
--network string Connect detect and build containers to network
-p, --path string Path to app dir or zip-formatted file (defaults to current working directory)
--publish Publish to registry
--pull-policy string Pull policy to use. Accepted values are always, never, and if-not-present. (default "always")
--run-image string Run image (defaults to default stack's run image)
-t, --tag strings Additional tags to push the output image to.
Repeat for each tag in order, or supply once by comma-separated list
--trust-builder Trust the provided builder
All lifecycle phases will be run in a single container (if supported by the lifecycle).
--volume stringArray Mount host volume into the build container, in the form '<host path>:<target path>[:<options>]'.
- 'host path': Name of the volume or absolute directory path to mount.
- 'target path': The path where the file or directory is available in the container.
- 'options' (default "ro"): An optional comma separated list of mount options.
- "ro", volume contents are read-only.
- "rw", volume contents are readable and writeable.
- "volume-opt=<key>=<value>", can be specified more than once, takes a key-value pair consisting of the option name and its value.
Repeat for each volume in order, or supply once by comma-separated list
Global Flags:
--no-color Disable color output
-q, --quiet Show less output
--timestamps Enable timestamps in output
-v, --verbose Show more output
Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net> Signed-off-by: skothari44 <skothari44@bloomberg.net>
0bd6e33
to
2209b65
Compare
The latest commit should address the standing comments :) Since the other flags in pack build didn't expose a default, I removed it for the lifecycle as well as it was getting confusing. |
✅ Accepted✅ pack build --help
|
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.
Signed-off-by: Sambhav Kothari skothari44@bloomberg.net
Summary
Adds the ability to provide a custom lifecycle image repository
Output
Before
After
Documentation
Related
Resolves #1083
Resolves #904