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 diff --git a/pkg/skaffold/docker/parse.go b/pkg/skaffold/docker/parse.go index af4229ca1e2..1e5f8c75bb7 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 @@ -267,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 @@ -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{}