pack icon indicating copy to clipboard operation
pack copied to clipboard

Add support for `pack build --label`

Open edmorley opened this issue 4 months ago • 3 comments

Description

The pack builder create and pack buildpack package commands both support a --label argument for adding OCI image labels to the builder and buildpacks images respectively, added in #2034 and #1877. Similarly, buildpacks can set app image labels via the [[labels]] table in launch.toml - for example as used by paketo-buildpacks/image-labels.

However, it's not currently possible to add labels to the app image when calling pack build.

This means that in https://github.com/basecamp/kamal/pull/916 the service label required by Kamal can't be set when calling pack build, and instead the paketo-buildpacks/image-labels buildpack has to be injected. This has a couple of downsides:

  1. The builder's default buildpack order is overridden, so now the user must always specify an explicit list of buildpacks rather than being able to rely on the curated defaults in the builder should they wish.
  2. Users may get confused why there are more buildpacks being run than the list of buildpacks they requested, given that an extra buildpack has had to be injected.

If pack build supported setting image labels natively, then there would be no need to use this buildpack injection based approach.

Proposed solution

Add --label support to pack build, similar to that already supported by pack builder create and pack buildpack package.

cc @nickhammond

edmorley avatar Oct 02 '24 16:10 edmorley