🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

incorrect target matcher in dockerfile autodiscovery #11466

Closed

Description

@jsahome

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

For a Dockerfile that contains these directives:

FROM caddy:2.11.4-builder AS builder

...

FROM caddy:2.11.4-alpine

The manifest has an entry for each of the images. The tag and version filters correctly restrict each to the appropriate suffix (i.e. -builder or -alpine). The matcher, however, just has caddy. The result is that both are overwritten to whichever rule is applied last.

The matcher should have the same restrictions as the tag filter and version filter.

Sample output from manifest show:

== DEPS(DOCKERFILE): BUMP "CADDY" DIGEST ==

name: 'deps(dockerfile): bump "caddy" digest'
pipelineid: 24d40fef7a4eb036aa937416c9f266e57d553c18f08d012917697ac9f0f2bfbf
sources:
    caddy:
        name: get latest image tag for "caddy"
        kind: dockerimage
        spec:
            image: caddy
            tagfilter: ^\d*(\.\d*){2}-builder$
            versionfilter:
                kind: semver
                pattern: '>=2.11.4-builder'
    caddy-digest:
        dependson:
            - caddy
        name: get latest image "caddy" digest
        kind: dockerdigest
        spec:
            image: caddy
            tag: '{{ source "caddy" }}'
targets:
    caddy:
        name: 'deps: update Docker image "caddy" to "{{ source "caddy" }}"'
        kind: dockerfile
        spec:
            file: caddy/Dockerfile
            instruction:
                keyword: FROM
                matcher: caddy
        sourceid: caddy-digest


== DEPS(DOCKERFILE): BUMP "CADDY" DIGEST ==

name: 'deps(dockerfile): bump "caddy" digest'
pipelineid: 24d40fef7a4eb036aa937416c9f266e57d553c18f08d012917697ac9f0f2bfbf
sources:
    caddy:
        name: get latest image tag for "caddy"
        kind: dockerimage
        spec:
            image: caddy
            tagfilter: ^\d*(\.\d*){2}-alpine$
            versionfilter:
                kind: semver
                pattern: '>=2.11.4-alpine'
    caddy-digest:
        dependson:
            - caddy
        name: get latest image "caddy" digest
        kind: dockerdigest
        spec:
            image: caddy
            tag: '{{ source "caddy" }}'
targets:
    caddy:
        name: 'deps: update Docker image "caddy" to "{{ source "caddy" }}"'
        kind: dockerfile
        spec:
            file: caddy/Dockerfile
            instruction:
                keyword: FROM
                matcher: caddy
        sourceid: caddy-digest

When running apply, the diff looks like:

index acdd32b..0037869 100644
--- a/caddy/Dockerfile
+++ b/caddy/Dockerfile
@@ -1,12 +1,12 @@

-FROM caddy:2.11.4-builder AS builder
+FROM caddy:2.11.9-alpine@sha256:003a97808e781aa9f7e75cc2f43d34d461099031faf5e20faefb9f61126836f0 AS builder

...

-FROM caddy:2.11.4-alpine
+FROM caddy:2.11.9-alpine@sha256:003a97808e781aa9f7e75cc2f43d34d461099031faf5e20faefb9f61126836f0

2.11.4-builder was updated to 2.11.9-alpine which is incorrect.

Expected Behavior

The Docker variant should stay the same: 2.11.4-builder should be updated to 2.11.9-builder.

Steps To Reproduce

Run updatecli on a directory that has a Dockerfile with the directives:

FROM caddy:2.11.4-builder AS builder
...
FROM caddy:2.11.4-alpine

and look at the diff.

Environment

- OS: AlmaLinux
- updatecli: v0.124.0

Pipeline Graph

== DEPS(DOCKERFILE): BUMP "CADDY" DIGEST ==

name: 'deps(dockerfile): bump "caddy" digest'
pipelineid: 24d40fef7a4eb036aa937416c9f266e57d553c18f08d012917697ac9f0f2bfbf
sources:
    caddy:
        name: get latest image tag for "caddy"
        kind: dockerimage
        spec:
            image: caddy
            tagfilter: ^\d*(\.\d*){2}-builder$
            versionfilter:
                kind: semver
                pattern: '>=2.11.4-builder'
    caddy-digest:
        dependson:
            - caddy
        name: get latest image "caddy" digest
        kind: dockerdigest
        spec:
            image: caddy
            tag: '{{ source "caddy" }}'
targets:
    caddy:
        name: 'deps: update Docker image "caddy" to "{{ source "caddy" }}"'
        kind: dockerfile
        spec:
            file: caddy/Dockerfile
            instruction:
                keyword: FROM
                matcher: caddy
        sourceid: caddy-digest


== DEPS(DOCKERFILE): BUMP "CADDY" DIGEST ==

name: 'deps(dockerfile): bump "caddy" digest'
pipelineid: 24d40fef7a4eb036aa937416c9f266e57d553c18f08d012917697ac9f0f2bfbf
sources:
    caddy:
        name: get latest image tag for "caddy"
        kind: dockerimage
        spec:
            image: caddy
            tagfilter: ^\d*(\.\d*){2}-alpine$
            versionfilter:
                kind: semver
                pattern: '>=2.11.4-alpine'
    caddy-digest:
        dependson:
            - caddy
        name: get latest image "caddy" digest
        kind: dockerdigest
        spec:
            image: caddy
            tag: '{{ source "caddy" }}'
targets:
    caddy:
        name: 'deps: update Docker image "caddy" to "{{ source "caddy" }}"'
        kind: dockerfile
        spec:
            file: caddy/Dockerfile
            instruction:
                keyword: FROM
                matcher: caddy
        sourceid: caddy-digest


diff --git a/caddy/Dockerfile b/caddy/Dockerfile
index acdd32b..0037869 100644
--- a/caddy/Dockerfile
+++ b/caddy/Dockerfile
@@ -1,12 +1,12 @@

-FROM caddy:2.11.4-builder AS builder
+FROM caddy:2.11.9-alpine@sha256:003a97808e781aa9f7e75cc2f43d34d461099031faf5e20faefb9f61126836f0 AS builder

...

-FROM caddy:2.11.4-alpine
+FROM caddy:2.11.9-alpine@sha256:003a97808e781aa9f7e75cc2f43d34d461099031faf5e20faefb9f61126836f0

 COPY --from=builder /usr/bin/caddy /usr/bin/caddy

OpenTelemetry Trace

No response

Anything else?

I'm going to attempt to fix this as I'd like to use updatecli and I'd rather fix autodiscovery than work around the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions