We're using Heroku Buildpacks inside a GitLab CI/CD pipeline by triggering a job running the heroku builder image and then invoking the /cnb/lifecycle/creator directly, instead of using the pack CLI. This is because be can't use docker in docker on our container orchestrator.
This all works fine and dandy, but we're facing the problem of not being able to specify any custom labels that will be added to the produced image. By default, these labels are added:
- io.buildpacks.lifecycle.metadata
- io.buildpacks.build.metadata
- io.buildpacks.project.metadata
But we'd also like to add the following labels:
- org.opencontainers.image.revision
- org.opencontainers.image.url
- org.opencontainers.image.source
- org.opencontainers.image.version
- org.opencontainers.image.licenses
- org.opencontainers.image.authors
Unfortunately there seems to be no way to specify this. The creator doesn't offer any configuration parameter to do this, neither the pack CLI as far as I could tell. When using Paketo buildpacks, there is indeed a designated buildpack to solve this: https://github.com/paketo-buildpacks/image-labels
Is there any way to do something similiar when using Heroku buildpacks?
CodePudding user response:
You can use the Paketo image-labels buildpack with the Heroku buildpacks. Here's an example of doing this from the pack
CLI:
$ pack build --builder heroku/buildpacks:20 --buildpack paketo-buildpacks/image-labels my-app
With the CLI you can add more --buildpack
options as needed.
If you want to codify this, you can create a project.toml
and use the io.buildpacks.post.group
to always run the image-labels buildpack at the end.
If you're using creator
binary, you can provide it a group.toml
https://github.com/buildpacks/spec/blob/main/platform.md#inputs-3