From 687a7c023ed407e8ab039b27386e2485dcff8403 Mon Sep 17 00:00:00 2001 From: Mariano Reingart Date: Mon, 8 Sep 2025 20:19:23 -0500 Subject: [PATCH 1/3] fix #9830: ignore unresolved parsed FROM in tagger --- pkg/skaffold/docker/parse.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/skaffold/docker/parse.go b/pkg/skaffold/docker/parse.go index af4229ca1e2..93311e233df 100644 --- a/pkg/skaffold/docker/parse.go +++ b/pkg/skaffold/docker/parse.go @@ -40,6 +40,8 @@ import ( "github.com/GoogleContainerTools/skaffold/v2/proto/v1" ) +const buildkitUnresolvedImagePlaceholder = "image:latest" + type FromTo struct { // From is the relative path (wrt. the skaffold root directory) of the dependency on the host system. From string @@ -386,7 +388,7 @@ func expandOnbuildInstructions(ctx context.Context, nodes []*parser.Node, cfg Co var onbuildNodes []*parser.Node if ons, found := onbuildNodesCache[strings.ToLower(from.image)]; found { onbuildNodes = ons - } else if from.image == "" { + } else if from.image == "" || from.image == buildkitUnresolvedImagePlaceholder { // some build args like artifact dependencies are not available until the first build sequence has completed. // skip check if there are unavailable images onbuildNodes = []*parser.Node{} From b31e5cb3510d21aa05bb5401508d41639c52d367 Mon Sep 17 00:00:00 2001 From: Mariano Reingart Date: Mon, 8 Sep 2025 20:40:59 -0500 Subject: [PATCH 2/3] refactor #9830: simple artifact dep example --- examples/simple-artifact-dependency/app/Dockerfile | 9 +++++++-- examples/simple-artifact-dependency/skaffold.yaml | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/simple-artifact-dependency/app/Dockerfile b/examples/simple-artifact-dependency/app/Dockerfile index 57dfed7ce53..1a25f16507c 100644 --- a/examples/simple-artifact-dependency/app/Dockerfile +++ b/examples/simple-artifact-dependency/app/Dockerfile @@ -1,5 +1,6 @@ ARG BASE -FROM golang:1.18 as builder + +FROM golang:1.18 AS builder WORKDIR /code COPY main.go . COPY go.mod . @@ -7,9 +8,13 @@ COPY go.mod . ARG SKAFFOLD_GO_GCFLAGS RUN go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -trimpath -o /app . -FROM $BASE +FROM $BASE AS base + +FROM scratch # Define GOTRACEBACK to mark this container as using the Go language runtime # for `skaffold debug` (https://skaffold.dev/docs/workflows/debug/). ENV GOTRACEBACK=single CMD ["./app"] COPY --from=builder /app . +COPY --from=base hello.txt . + diff --git a/examples/simple-artifact-dependency/skaffold.yaml b/examples/simple-artifact-dependency/skaffold.yaml index 7f4bf90e996..c5dfc73a3e2 100644 --- a/examples/simple-artifact-dependency/skaffold.yaml +++ b/examples/simple-artifact-dependency/skaffold.yaml @@ -9,6 +9,8 @@ build: alias: BASE - image: base context: base + tagPolicy: + inputDigest: {} manifests: rawYaml: - app/k8s-pod.yaml From b6e410bde2823c6f3abe77a9f7e368191d428ae9 Mon Sep 17 00:00:00 2001 From: Mariano Reingart Date: Wed, 8 Oct 2025 21:00:56 -0500 Subject: [PATCH 3/3] fix: ignore image:latest when parsing FORM Similar to ONBUILD, when it tries to expand the COPY, it was short-circuiting and returning a empty dep list if the bogous image was found (due the Dockerfile parser issue) --- pkg/skaffold/docker/parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/skaffold/docker/parse.go b/pkg/skaffold/docker/parse.go index 93311e233df..1e5f8c75bb7 100644 --- a/pkg/skaffold/docker/parse.go +++ b/pkg/skaffold/docker/parse.go @@ -269,7 +269,7 @@ func extractCopyCommands(ctx context.Context, nodes []*parser.Node, onlyLastImag stages[strings.ToLower(from.as)] = true } - if from.image == "" { + if from.image == "" || from.image == buildkitUnresolvedImagePlaceholder { // some build args like artifact dependencies are not available until the first build sequence has completed. // skip check if there are unavailable images continue