thegeeklab / wp-docker-buildx

Woodpecker CI plugin to build multiarch OCI images with buildx
https://woodpecker-plugins.geekdocs.de/plugins/wp-docker-buildx
Apache License 2.0
0 stars 0 forks source link

Define common opencontainer labels automatically #280

Open pat-s opened 1 week ago

pat-s commented 1 week ago

In the official buildx plugin some labels are automatically set by the plugin by inferring information from the build context.

One of these, org.opencontainers.image.created is also somewhat important as e.g. artifacthub.io requires it for some metadata extraction.

For now I can workaround this via date -u +"%Y-%m-%dT%H:%M:%SZ") explicitly but it would be great to have support for this within the plugin.

xoxys commented 1 week ago

I'm not a fan to set any label automatically. But there is https://github.com/thegeeklab/wp-docker-buildx/blob/main/docker/docker.go#L105 already. You can just use consume it in your containerfile:

LABEL org.opencontainers.image.created=$DOCKER_IMAGE_CREATED
pat-s commented 1 week ago

Ah, thanks!

The following works:

ARG DOCKER_IMAGE_CREATED

LABEL org.opencontainers.image.created="${DOCKER_IMAGE_CREATED}" 
xoxys commented 1 week ago

Do you still think there should at least an option to auto-set the openconainer labels?

pat-s commented 1 week ago

I think so yes, but I understand your reasoning not wanting to set any label by default.

One could even argue that the added value of a plugin is to simplify things like that for users but I am also OK with the workaround 🙂️

xoxys commented 1 week ago

Alright you convinced me. Lets add them but disabled by default by a settings flag?

pat-s commented 1 week ago

That would be great! And yes, if there's a flag and a choice for the user, it should likely be disabled by default.