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

Strategy to pass --label to build command #149

Open
consideRatio opened this issue Mar 1, 2022 · 0 comments
Open

Strategy to pass --label to build command #149

consideRatio opened this issue Mar 1, 2022 · 0 comments

Comments

@consideRatio
Copy link
Member

consideRatio commented Mar 1, 2022

I'd like to use chartpress together with the docker/metadata-action that provides standardized image labels and values - to set a few labels on built images. When using ghcr.io, you often want to couple a built image with a GitHub repository, and the OCI standardized labels can help do that.

The docker/metadata-action can emit the following labels for example.

        "org.opencontainers.image.title": "Hello-World",
        "org.opencontainers.image.description": "This your first repo!",
        "org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
        "org.opencontainers.image.source": "https://github.com/octocat/Hello-World",
        "org.opencontainers.image.version": "1.2.3",
        "org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
        "org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
        "org.opencontainers.image.licenses": "MIT"

#142 would add support for declaring extraBuildCommandOptions in chartpress.yaml to set labels via --labels flag, but updating chartpress.yaml dynamically wouldn't be a good idea as that is a hint for chartpress to rebuild all images etc as well. So, either there is something fixed in chartpress.yaml that makes use of the expanded variables like...

            expansion_namespace = {
                "LAST_COMMIT": _get_latest_commit_tagged_or_modifying_paths(
                    *all_image_paths, echo=False
                ),
                "TAG": image_tag,
            }

Brainstorming

  1. chartpress to automatically pass --labels?
  2. Updating Dockerfile with --build-args to set labels?
  3. Updating chartpress.yaml with Allow extra options to be passed to docker build #142 and namespace expansion of LAST_COMMIT etc to set for example org.opencontainers.image.revision and org.opencontainers.image.version to reference TAG?

I'm leaning towards the idea of bypassing use of docker/metadata-action and relying entirely on namespace expansion and the new #142 feature, where we could perhaps also add a date expansion to support setting org.opencontainers.image.created.

@consideRatio consideRatio changed the title Passing labels Passing labels to build command Mar 1, 2022
@consideRatio consideRatio changed the title Passing labels to build command Strategy to pass --label to build command Mar 1, 2022
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

1 participant