Skip to content

Strategy to pass --label to build command #149

Open
@consideRatio

Description

@consideRatio

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions