pack icon indicating copy to clipboard operation
pack copied to clipboard

Make `pack build --buildpack <path>` apply configuration in `package.toml`

Open edmorley opened this issue 3 years ago • 1 comments

Description

Currently if pack build --buildpack <path> points at a directory containing a package.toml, the package.toml file is ignored, and instead the directory is packaged into an ephemeral builder image using the default settings. ie: It's as though this were in package.toml:

[buildpack]
uri = "."

This means it's not possible to build/test meta-buildpacks with --buildpack <path to meta-buildpack> when developing locally.

In order to the configuration in package.toml be used, pack buildpack package has to be run first, then pack build --buildpack <CNB file or OCI image reference> be used instead.

This is unfortunate, since it means in local development testing workflows, a redundant .cnb or OCI image packaging step has to be performed after each code change, which:

  1. Is slower than running with --buildpack <path> (having a .cnb or OCI image doesn't make the pack build any faster)
  2. Makes parallel testing more cumbersome, due to having to avoid race conditions in .cnb/OCI image teardown

Proposed solution

It would be great if pack build --buildpack <path> instead checked for the presence of a package.toml and used the configuration there when creating the ephemeral builder, rather than using the defaults mentioned above.

edmorley avatar Nov 09 '21 10:11 edmorley

It looks like --buildpack <path> buildpacks are handled here during pack build: https://github.com/buildpacks/pack/blob/26d8c5c5607933c6d0738f3c37370c87d2e134f1/pkg/client/build.go#L743-L760

In comparison, this is how pack buildpack package handles them: https://github.com/buildpacks/pack/blob/522eca8eda5ef8bf400455719b95d29238eda093/pkg/client/package_buildpack.go#L82-L140

edmorley avatar Nov 09 '21 11:11 edmorley