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

overwrite OCI source label in image #60

Merged
merged 1 commit into from
Jan 8, 2025
Merged

Conversation

Preisschild
Copy link
Contributor

Currently, this label is set to
https://github.com/chainguard-images/images/tree/main/images/static (because the ko base image is this chainguard image).

This leads to issues with dependency managers like renovate, which uses this label to parse the change log.

Setting this label to the correct source URL fixes such problems.

More Information on those labels:

https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys

ko-build/ko#1395

https://docs.renovatebot.com/modules/datasource/docker/#description

@ahrtr
Copy link
Owner

ahrtr commented Jan 7, 2025

Thanks @Preisschild for the contribution, which looks good to me.

I see that you closed #59, which sets label in Dockerfile. It might be a little better than this PR?

Also could you please update all the labels (exclude org.opencontainers.image.created) below?

            "Labels": {
                "dev.chainguard.package.main": "",
                "org.opencontainers.image.authors": "Chainguard Team https://www.chainguard.dev/",
                "org.opencontainers.image.created": "2024-11-12T12:01:47Z",
                "org.opencontainers.image.source": "https://github.com/chainguard-images/images/tree/main/images/static",
                "org.opencontainers.image.url": "https://images.chainguard.dev/directory/image/static/overview",
                "org.opencontainers.image.vendor": "Chainguard"
            }
$ nerdctl inspect ghcr.io/ahrtr/etcd-defrag:v0.20.0
[
    {
        "Id": "sha256:24b539cd3c4787ba38a9e99fc4c4d521f2092da4df7e72cb087082dd729e6d5f",
        "RepoTags": [
            "ghcr.io/ahrtr/etcd-defrag:v0.20.0"
        ],
        "RepoDigests": [
            "ghcr.io/ahrtr/etcd-defrag@sha256:8a4e0c9ee4f1932d7678d21d7d0ea90a6c165283a23724cad3b6fe7a94434423"
        ],
        "Parent": "",
        "Comment": "go build output, at /ko-app/etcd-defrag",
        "Created": "0001-01-01T00:00:00Z",
        "DockerVersion": "",
        "Author": "ko",
        "Config": {
            "User": "65532",
            "AttachStdin": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/ko-app",
                "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt",
                "KO_DATA_PATH=/var/run/ko"
            ],
            "Entrypoint": [
                "/ko-app/etcd-defrag"
            ],
            "Labels": {
                "dev.chainguard.package.main": "",
                "org.opencontainers.image.authors": "Chainguard Team https://www.chainguard.dev/",
                "org.opencontainers.image.created": "2024-11-12T12:01:47Z",
                "org.opencontainers.image.source": "https://github.com/chainguard-images/images/tree/main/images/static",
                "org.opencontainers.image.url": "https://images.chainguard.dev/directory/image/static/overview",
                "org.opencontainers.image.vendor": "Chainguard"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 23740416,
        "VirtualSize": 23740416,
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:8eb6febda7cc907037aa1c02572d986ecc7415f79f403822e2f79af7b96467b8",
                "sha256:ffe56a1c5f3878e9b5f803842adb9e2ce81584b6bd027e8599582aefe14a975b",
                "sha256:3ba88712e6abb1697d9ec99930f25d127fe320e00dbf26b75bb95980a3fb70f3"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

cc @clementnuss

@Preisschild
Copy link
Contributor Author

I see that you closed #59, which sets label in Dockerfile. It might be a little better than this PR?

The dockerfile is unused for the ko-build as far as I understand, but I can add it there too.

Also could you please update all the labels

will do.

@ahrtr
Copy link
Owner

ahrtr commented Jan 7, 2025

The dockerfile is unused for the ko-build as far as I understand, but I can add it there too.

You are right.

Unfortunately, ko.yaml doesn't support configuring the image labels yet.

ko-build/ko#825

@Preisschild Preisschild force-pushed the patch-1 branch 2 times, most recently from de25473 to 637ad77 Compare January 7, 2025 17:22
@Preisschild
Copy link
Contributor Author

Preisschild commented Jan 7, 2025

I also removed the duplicate ko build step. I dont think there is a reason for that, as --tags accepts multiple tags anyways.

(when --tags is absent, the default latest is used)

@Preisschild Preisschild force-pushed the patch-1 branch 3 times, most recently from d16c6ce to 2aa7e0b Compare January 8, 2025 07:36
Currently, this label is set to
`https://github.com/chainguard-images/images/tree/main/images/static`
(because the ko base image is this chainguard image).

This leads to issues with dependency managers like renovate, which uses
this label to parse the change log.

Setting this label to the correct source URL fixes such problems.

More Information on those labels:

https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys

ko-build/ko#1395

https://docs.renovatebot.com/modules/datasource/docker/#description
Signed-off-by: Florian Ströger <[email protected]>
Copy link
Owner

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you @Preisschild

@ahrtr ahrtr merged commit 16c2f46 into ahrtr:main Jan 8, 2025
@ahrtr
Copy link
Owner

ahrtr commented Jan 8, 2025

Will release a new version today or tomorrow.

@ahrtr
Copy link
Owner

ahrtr commented Jan 9, 2025

Just released https://github.com/ahrtr/etcd-defrag/releases/tag/v0.21.0

The latest labels:

$ nerdctl inspect ghcr.io/ahrtr/etcd-defrag:v0.21.0
[
    {
        "Id": "sha256:9d0f109dc527934298fc981eccb488cfba7c338b460b38afbf85a9c7bf3aa7d3",
        "RepoTags": [
            "ghcr.io/ahrtr/etcd-defrag:v0.21.0"
        ],
        "RepoDigests": [
            "ghcr.io/ahrtr/etcd-defrag@sha256:9d5d9a57950cffc441059c0e10572cfe9427852f8940d3ea101a06e43a1bf41c"
        ],
        "Parent": "",
        "Comment": "go build output, at /ko-app/etcd-defrag",
        "Created": "0001-01-01T00:00:00Z",
        "DockerVersion": "",
        "Author": "ko",
        "Config": {
            "User": "65532",
            "AttachStdin": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/ko-app",
                "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt",
                "KO_DATA_PATH=/var/run/ko"
            ],
            "Entrypoint": [
                "/ko-app/etcd-defrag"
            ],
            "Labels": {
                "dev.chainguard.package.main": "",
                "org.opencontainers.image.authors": "ahrtr",
                "org.opencontainers.image.created": "2025-01-09T14:48:39Z",
                "org.opencontainers.image.source": "https://github.com/ahrtr/etcd-defrag",
                "org.opencontainers.image.url": "https://ghcr.io/ahrtr/etcd-defrag",
                "org.opencontainers.image.vendor": "ahrtr"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 23740416,
        "VirtualSize": 23740416,
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:126da8fab2171b3df92e137f7f19f72cb060436742078db3e4d4b05474a961c6",
                "sha256:ffe56a1c5f3878e9b5f803842adb9e2ce81584b6bd027e8599582aefe14a975b",
                "sha256:92f7d52f615c875241572014f85d9de1b073497c28045daa11b5d49362947e36"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

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

Successfully merging this pull request may close these issues.

2 participants