buildpacks / pack

CLI for building apps using Cloud Native Buildpacks
https://buildpacks.io
Apache License 2.0
2.57k stars 287 forks source link

Set org.opencontainers.image.source From project.source-url #1049

Open jamesward opened 3 years ago

jamesward commented 3 years ago

I was trying to set the org.opencontainers.image.source label in a container created by pack but it always gets set to the url for my buildpack despite setting the project.source-url: https://github.com/jamesward/easycloudrun/blob/main/project.toml

dfreilich commented 3 years ago

Wow. Looking at the schema, we definitely need to add more to fulfill the implementation of it.

I don't see, in the RFC (https://github.com/buildpacks/rfcs/pull/32), a description of expected behavior with project.source-url → @jkutner , is that what you would expect for project.source-url?

ekcasey commented 3 years ago

@dfreilich Not sure how this interacts with source-url in project.toml and org.opencontainers.image.source but I thought at one point there was a plan to have pack read git metadata at pass project-metadata.toml to the lifecycle, which would in turn set io.buildpacks.project.metadata

jromero commented 3 years ago
  1. This seems like something the lifecycle should do. Is there an RFC or anything on the spec talking about setting predefined OCI annotations?
  2. As @dfreilich noticed, we are probably missing a good bit here in supporting project.toml and project-metadata.toml
  3. There is a related issue to @ekcasey comment here: https://github.com/buildpacks/pack/issues/446
jromero commented 3 years ago

In an effort to reproduce the report here are the steps I took:

❯ gh repo clone jamesward/easycloudrun
Cloning into 'easycloudrun'...
...

/tmp on ☁️ rjavier@vmware.com
❯ cd easycloudrun/

easycloudrun on  main on ☁️ rjavier@vmware.com
❯ pack build ghcr.io/jamesward/easycloudrun --buildpack ghcr.io/jamesward/gcloud-buildpack --builder gcr.io/buildpacks/builder:v1 --run-image ghcr.io/jamesward/gcloud-buildpack-run
v1: Pulling from buildpacks/builder
9f2825a1003a: Pull complete
...
Digest: sha256:a71080cf7b7b14fac4557d157a374a07892dd531e07408fc95ee025c6bdd0741
Status: Downloaded newer image for gcr.io/buildpacks/builder:v1
latest: Pulling from jamesward/gcloud-buildpack-run
...
b898f13db3be: Pull complete
Digest: sha256:3cefe8fee6fa35551b0cf0b4d88b61feca5854fda57e06d73a88ea5fb542b519
Status: Downloaded newer image for ghcr.io/jamesward/gcloud-buildpack-run:latest
latest: Pulling from jamesward/gcloud-buildpack
678a08b66018: Pull complete
Digest: sha256:110efac0f1f629aff71be40f5a32c0dc6ccdd128872a84a8e9ac137898a790c3
Status: Downloaded newer image for ghcr.io/jamesward/gcloud-buildpack:latest
===> DETECTING
jamesward/gcloud 0.0.1
===> ANALYZING
Previous image with name "ghcr.io/jamesward/easycloudrun" not found
===> RESTORING
===> BUILDING
---> Creating process: appsecret
---> Creating process: deploywithenvs
---> Creating process: listservices
---> Creating process: multiregion
===> EXPORTING
Adding layer 'jamesward/gcloud:app'
Adding 1/1 app layer(s)
Adding layer 'launcher'
Adding layer 'config'
Adding layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Warning: default process type 'web' not present in list [appsecret deploywithenvs listservices multiregion]
*** Images (0eb884d3c2cb):
      ghcr.io/jamesward/easycloudrun
Successfully built image ghcr.io/jamesward/easycloudrun

easycloudrun on  main on ☁️ rjavier@vmware.com took 2m26s
❯ docker inspect ghcr.io/jamesward/easycloudrun | jq -r '.[0].Config.Labels'
{
  "io.buildpacks.build.metadata": "{\"bom\":null,\"buildpacks\":[{\"id\":\"jamesward/gcloud\",\"version\":\"0.0.1\",\"homepage\":\"https://github.com/jamesward/gcloud-buildpack\"}],\"launcher\":{\"version\":\"0.10.2\",\"source\":{\"git\":{\"repository\":\"github.com/buildpacks/lifecycle\",\"commit\":\"960cf58\"}}},\"processes\":[{\"type\":\"appsecret\",\"command\":\"/layers/jamesward_gcloud/app/appsecret.sh\",\"args\":null,\"direct\":true,\"buildpackID\":\"jamesward/gcloud\"},{\"type\":\"deploywithenvs\",\"command\":\"/layers/jamesward_gcloud/app/deploywithenvs.sh\",\"args\":null,\"direct\":true,\"buildpackID\":\"jamesward/gcloud\"},{\"type\":\"listservices\",\"command\":\"/layers/jamesward_gcloud/app/listservices.sh\",\"args\":null,\"direct\":true,\"buildpackID\":\"jamesward/gcloud\"},{\"type\":\"multiregion\",\"command\":\"/layers/jamesward_gcloud/app/multiregion.sh\",\"args\":null,\"direct\":true,\"buildpackID\":\"jamesward/gcloud\"}]}",
  "io.buildpacks.lifecycle.metadata": "{\"app\":[{\"sha\":\"sha256:7e38e40786d4aa9c7ffa2f5d61440a02b54e8cd07c5346eb67d2155fac97e8e8\"}],\"buildpacks\":[{\"key\":\"jamesward/gcloud\",\"version\":\"0.0.1\",\"layers\":{\"app\":{\"sha\":\"sha256:4071f8bbdd82f7a722b9d7d618a6579efc70a6481e89da51f9597d7eb08d618c\",\"data\":null,\"build\":false,\"launch\":true,\"cache\":false}}}],\"config\":{\"sha\":\"sha256:7496e66d5befcc216bc07b306c636da09eaa338eeba5ab153283340d4604679c\"},\"launcher\":{\"sha\":\"sha256:576e5f5696c6fcae9b679dca450d7ab127176f5c529bc9790b42abb9e3658cfa\"},\"process-types\":{\"sha\":\"sha256:0bea18cf40be4650397f350275053f59837eb3ded93927c9fc5c3758ed17d297\"},\"runImage\":{\"topLayer\":\"sha256:76e910db79bb06cfc4a0317db0b06e686295a58e242f62a3e63031261224ec2f\",\"reference\":\"90eec569e02884b967351b4c7b39bb68ea7f53bfeedf795a212dbc6b8b1eb5e2\"},\"stack\":{\"runImage\":{\"image\":\"gcr.io/buildpacks/gcp/run:v1\"}}}",
  "io.buildpacks.project.metadata": "{}",
  "io.buildpacks.stack.id": "google",
  "org.opencontainers.image.source": "https://github.com/jamesward/gcloud-buildpack"
}

Found that the label org.opencontainers.image.source is being set on the run image.

❯ docker inspect ghcr.io/jamesward/gcloud-buildpack-run | jq -r '.[0].Config.Labels'
{
  "io.buildpacks.stack.id": "google",
  "org.opencontainers.image.source": "https://github.com/jamesward/gcloud-buildpack"
}
jromero commented 3 years ago

@ekcasey given my comment above do you think it's best that we move this to the lifecycle and add the status/requires-rfc status?

jromero commented 3 years ago

Discussion started for this feature request. Please vote/contribute to it.

jjbustamante commented 1 year ago

The following RFC proposes that a buildpack can add arbitrary annotations to an image, today buildpacks can add arbitrary labels to an image.

RFC is in draft state, if anyone in the community is willing to push it forward we are more than happy to help and guide you!

jjbustamante commented 1 year ago

Block on RFC 196

natalieparellano commented 4 months ago

https://github.com/buildpacks/rfcs/pull/196 is superseded, please consult https://github.com/buildpacks/rfcs/pull/314