GoogleContainerTools / GoogleContainerTools/skaffold

watcher breaks with dockerfile using COPY --parents

Open
#9,411 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

### Expected behavior
A dockerfile utilizing the `COPY --parents .....` instruction should properly detect a list of files that are dependencies and rebuild on change when running `skaffold dev`
### Actual behavior
running `skaffold dev` builds once but does not detect any changes so it never rebuilds again (even on sequential runs of `skaffold dev`)
### Information
Dockerfile
```
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.20 AS build-stage

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download
COPY --parents ./vendor go.mod go.sum ./
COPY --parents ./**/*.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /binary /app/cmd/main.go

# Deploy the application binary into a lean image
FROM gcr.io/distroless/base-debian11 AS build-release-stage

WORKDIR /

COPY --from=build-stage /binary /binary

USER nonroot:nonroot

ENTRYPOINT ["/binary"]
```

- Skaffold version: `v2.11.0`
- Operating system: `Amazon Linux 2023`
- Installed via: skaffold curl command
- Contents of skaffold.yaml:

```yaml
# nonk8s
apiVersion: skaffold/v4beta10 # version of the configuration.
kind: Config
metadata:
name: REPO_NAME
build:
artifacts:
- image: REGISTRY_URL/IMAGE_NAME
context: .
docker:
dockerfile: cmd/Dockerfile
local:
useBuildkit: true
useDockerCLI: true
deploy:
helm:
releases:
- name: PACKAGE_NAME
chartPath: helm
setValueTemplates:
devicectl.image: "{{.IMAGE_FULLY_QUALIFIED_REGISTRY_URL_IMAGE_NAME}}"
createNamespace: true
profiles:
- name: helm-debug
patches:
- op: add
path: /deploy/helm/flags
value:
global:
- --debug
- name: staging
patches:
- op: add
path: /deploy/helm/releases/0/valuesFiles
value: ["helm/values-staging.yaml"]
- name: dev
activation:
- command: dev
patches:
- op: add
path: /deploy/helm/releases/0/valuesFiles
value: [ "helm/values-dev.yaml" ]
```

### Steps to reproduce the behavior

1. `skaffold dev`
2. build completes and shows watching for changes

Debug logging

There is a line after `Watching for changes
```
DEBU[0006] Found dependencies for dockerfile: [all go files that are one directory level down, not recursively down (ex /cmd/main.go is listed but /cmd/pkg/dependency.go is not]
```

If I replace
```
COPY --parents ./vendor go.mod go.sum ./
COPY --parents ./**/*.go ./
```
with
```
COPY . .
```
dependencies work just fine (but then I am bringing a lot of unnecessary files into the build context and triggering rebuilds even when code isn't changjng)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.