GoogleContainerTools / GoogleContainerTools/skaffold
Empty context using ONBUILD COPY
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
Hello,
I have trouble using ONBUILD COPY with skaffold.
Here a simple config to reproduce:
dockerfile:
```
FROM alpine as onbuild
ONBUILD COPY . /work
ONBUILD RUN ls -al /work/*
FROM onbuild
RUN cat /work/README.md
```
skaffold.yaml:
```yaml
apiVersion: skaffold/v3
kind: Config
metadata:
name: test-onbuild
build:
local:
push: false
artifacts:
- image: test
context: .
docker:
noCache: true
```
and a README.md file
### Expected behavior
I expected same result as docker build without skaffold
```
$ docker build . -t test --no-cache
Sending build context to Docker daemon 4.608kB
Step 1/5 : FROM alpine as onbuild
---> 9c6f07244728
Step 2/5 : ONBUILD COPY . /work
---> Running in 03a425d99524
Removing intermediate container 03a425d99524
---> 3412a45a3b4c
Step 3/5 : ONBUILD RUN ls -al /work/*
---> Running in 500aa0a69e6b
Removing intermediate container 500aa0a69e6b
---> 645ef0b4c75e
Step 4/5 : FROM onbuild
# Executing 2 build triggers
---> Running in e628887c265f
-rw-r--r-- 1 root root 109 Oct 31 14:55 /work/Dockerfile
-rw-r--r-- 1 root root 28 Oct 31 14:56 /work/README.md
-rw-r--r-- 1 root root 187 Oct 31 14:57 /work/skaffold.yaml
Removing intermediate container e628887c265f
---> 99eaea63afe1
Step 5/5 : RUN cat /work/README.md
---> Running in df2a9d732306
# ONBUILD with skaffold bug
Removing intermediate container df2a9d732306
---> 4bbffb364c06
Successfully built 4bbffb364c06
Successfully tagged test:latest
```
### Actual behavior
skaffold build result:
```
$ skaffold build
Generating tags...
- test -> test:latest
Some taggers failed. Rerun with -vdebug for errors.
Checking cache...
- test: Not found. Building
Starting build...
Building [test]...
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM alpine as onbuild
---> 9c6f07244728
Step 2/5 : ONBUILD COPY . /work
---> Running in 7c3389765d47
---> 9fdbb5fc4cf1
Step 3/5 : ONBUILD RUN ls -al /work/*
---> Running in cae9d0628a14
---> ad5cbe1e00dd
Step 4/5 : FROM onbuild
# Executing 2 build triggers
---> Running in f32254b714c3
-rw-r--r-- 1 root root 109 Oct 31 14:55 /work/Dockerfile
---> 9191780082c3
Step 5/5 : RUN cat /work/README.md
---> Running in 94a985740ac3
cat: can't open '/work/README.md': No such file or directory
docker build failure: The command '/bin/sh -c cat /work/README.md' returned a non-zero code: 1. Please fix the Dockerfile and try again..
```
As you can see, only Dockerfile is included in context, no other file...
### Information
- Skaffold version: v2.0.0
- Operating system: Ubuntu 20.04 on WSL2
- Installed via: skaffold.dev
### Additional context
I want ONBUILD COPY to do conditional copy as here: https://stackoverflow.com/a/54245466/13934411
Contributor guide
Assessment
This issue has not been assessed yet.