Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define common opencontainer labels automatically #280

Open
pat-s opened this issue Nov 19, 2024 · 6 comments
Open

Define common opencontainer labels automatically #280

pat-s opened this issue Nov 19, 2024 · 6 comments

Comments

@pat-s
Copy link
Contributor

pat-s commented Nov 19, 2024

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
Copy link
Member

xoxys commented Nov 19, 2024

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
Copy link
Contributor Author

pat-s commented Nov 19, 2024

Ah, thanks!

The following works:

ARG DOCKER_IMAGE_CREATED

LABEL org.opencontainers.image.created="${DOCKER_IMAGE_CREATED}" 

@pat-s pat-s closed this as completed Nov 19, 2024
@xoxys
Copy link
Member

xoxys commented Nov 19, 2024

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

@pat-s
Copy link
Contributor Author

pat-s commented Nov 19, 2024

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
Copy link
Member

xoxys commented Nov 19, 2024

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

@pat-s
Copy link
Contributor Author

pat-s commented Nov 19, 2024

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

@xoxys xoxys reopened this Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants