GoogleContainerTools / GoogleContainerTools/skaffold
Bug: Skaffold tagger ignores Docker target when calculating image tags
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
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
1. Create a `Dockerfile` with multiple targets:
```Dockerfile
FROM alpine as base
FROM base as dev
RUN touch devbuild
FROM base as prod
RUN touch prodbuild
```
2. Configure `skaffold.yaml` with different profiles using different targets:
```yaml
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
```
3. Run skaffold with different profiles:
```bash
$ 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.
Contributor guide
Assessment
This issue has not been assessed yet.