-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Environment
- Skaffold version: v2.16.0
- OS: Linux
- Docker version: Docker version 28.2.2, build e6534b4
Description
Skaffold generates identical image tags for different build profiles when the only difference is the Docker build target. This causes duplicate images to be built and pushed, wasting CI/CD resources and creating ambiguity about which variant is deployed.
Steps to Reproduce
- Create a
Dockerfile
with multiple targets:FROM alpine as base FROM base as dev RUN touch devbuild FROM base as prod RUN touch prodbuild
- Configure
skaffold.yaml
with different profiles using different targets:apiVersion: skaffold/v4beta11 kind: Config profiles: - name: dev activation: - command: dev build: tagPolicy: inputDigest: {} local: concurrency: 0 useBuildkit: true tryImportMissing: true artifacts: - image: out-image context: . docker: dockerfile: Dockerfile target: dev - name: prod activation: - command: prod build: tagPolicy: inputDigest: {} local: concurrency: 0 useBuildkit: true tryImportMissing: true artifacts: - image: out-image context: . docker: dockerfile: Dockerfile target: prod
- Run skaffold with different profiles:
$ skaffold build --profile dev --dry-run Generating tags... - out-image -> out-image:dd0bcd52c53d80e2a77a84d416883ce1804609153de66be26341326f945233c5 Skipping build phase since --dry-run=true $ skaffold build --profile prod --dry-run Generating tags... - out-image -> out-image:dd0bcd52c53d80e2a77a84d416883ce1804609153de66be26341326f945233c5 Skipping build phase since --dry-run=true
Expected Behavior
Skaffold should generate different image tags for different profiles when they use different Docker build targets, as they produce functionally different images.
Actual Behavior
Skaffold generates identical image tags for both profiles:
out-image:dd0bcd52c53d80e2a77a84d416883ce1804609153de66be26341326f945233c5
Impact
- Ambiguity about which image variant (dev or production) is actually deployed
- Potential for development images to be deployed in production environments
- CI/CD pipelines build and push redundant images
Possible Solution
Modify the checksum calculation in the Skaffold tagger to include the Docker target as part of the input when generating image tags.
Metadata
Metadata
Assignees
Labels
No labels