Skip to content
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

Merged
merged 1 commit into from
Mar 1, 2021
Merged

Conversation

sambhav
Copy link
Member

@sambhav sambhav commented Feb 23, 2021

Signed-off-by: Sambhav Kothari skothari44@bloomberg.net

Summary

Adds the ability to provide a custom lifecycle image repository

Output

Before

After

Documentation

  • Should this change be documented?
    • Yes, see #___
    • No

Related

Resolves #1083
Resolves #904

@sambhav sambhav requested a review from a team as a code owner February 23, 2021 00:14
@github-actions github-actions bot added this to the 0.18.0 milestone Feb 23, 2021
@github-actions github-actions bot added type/chore Issue that requests non-user facing changes. type/enhancement Issue that requests a new feature or improvement. labels Feb 23, 2021
@codecov
Copy link

codecov bot commented Feb 23, 2021

Codecov Report

Merging #1088 (ce27c9e) into main (0c84b4a) will increase coverage by 0.17%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Flag Coverage Δ
os_linux 79.88% <100.00%> (+0.16%) ⬆️
os_macos 77.41% <100.00%> (+0.22%) ⬆️
os_windows 80.48% <100.00%> (+0.17%) ⬆️
unit 79.96% <100.00%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@sambhav sambhav changed the title Add a custom lifecycle repo Add a custom lifecycle repo flag Feb 23, 2021
@sambhav sambhav force-pushed the custom-lifecycle branch 2 times, most recently from a042662 to 36c6124 Compare February 23, 2021 11:15
Copy link
Member

@jromero jromero left a 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()),
Copy link
Member

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

Copy link
Member Author

@sambhav sambhav Feb 23, 2021

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 :)

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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.

@sambhav
Copy link
Member Author

sambhav commented Feb 24, 2021

Updated to use lifecycle-image instead.

@sambhav sambhav changed the title Add a custom lifecycle repo flag Add a custom lifecycle image flag Feb 24, 2021
@ekcasey
Copy link
Member

ekcasey commented Feb 24, 2021

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 ?

@jromero
Copy link
Member

jromero commented Feb 24, 2021

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.

@sambhav
Copy link
Member Author

sambhav commented Feb 24, 2021

That makes sense, is this PR ready for merging then?

@sambhav
Copy link
Member Author

sambhav commented Feb 24, 2021

does this issue capture the above discussion #1091?

Please feel free to make edits if I misunderstood something.

@@ -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.`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.`)

Copy link
Member

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.

Copy link
Member

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() {
Copy link
Member

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!

Copy link
Member

@jromero jromero left a 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>
@sambhav
Copy link
Member Author

sambhav commented Feb 26, 2021

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.

@jromero
Copy link
Member

jromero commented Mar 1, 2021

✅ Accepted

✅ pack build --help

❯ pack-dev config lifecycle-image --unset
No custom lifecycle image was set.

~ on ☁️ rjavier@vmware.com
❯ pack-dev build --help | grep lifecycle-image -A 2
      --lifecycle-image string      Custom lifecycle image to use for analysis, restore, and export when builder is untrusted.
      --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)

~ on ☁️ rjavier@vmware.com
❯ pack-dev config lifecycle-image buildpacksio/lifecycle:0.10.1
Image buildpacksio/lifecycle:0.10.1 will now be used as the lifecycle image

~ on ☁️ rjavier@vmware.com
❯ pack-dev build --help | grep lifecycle-image -A 2
      --lifecycle-image string      Custom lifecycle image to use for analysis, restore, and export when builder is untrusted. (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)

Copy link
Member

@jromero jromero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

@jromero jromero removed the type/chore Issue that requests non-user facing changes. label Mar 1, 2021
@jromero jromero merged commit 658dec2 into buildpacks:main Mar 1, 2021
@sambhav sambhav deleted the custom-lifecycle branch March 1, 2021 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
4 participants