Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multistage builds not copying files #615

Closed
nfvs opened this issue Mar 13, 2019 · 3 comments · Fixed by #621
Closed

Multistage builds not copying files #615

nfvs opened this issue Mar 13, 2019 · 3 comments · Fixed by #621

Comments

@nfvs
Copy link

nfvs commented Mar 13, 2019

Actual behavior
Files that are generated in a stage do not get copied over in the next stages.

Expected behavior
Files should get copied over to the next stages

To Reproduce
Steps to reproduce the behavior:

  1. Build a simple two-stage image
FROM python:3.5 AS builder
RUN pip install virtualenv
RUN virtualenv /venv -p python3

FROM python:3.5-slim
COPY --from=builder /venv /venv
  1. Inspecting the resulting image, we notice there is no /venv. Also this output:
INFO[0117] Taking snapshot of full filesystem...        
INFO[0118] COPY --from=builder /venv /venv              
INFO[0119] Taking snapshot of full filesystem...        
INFO[0119] No files were changed, appending empty layer to config. No layer added to image. 

Additional Information

  • Runing this in GitLab using gcr.io/kaniko-project/executor:debug (tested sha256:642ef6209052ed2d96bfc20d2edc2803300ce3d858773629683b6d0903624777 and sha256:3c820e1112b24421d103582dbf27e7fca05b4eb335adaadca3d616d3d48689b9)
  • Works fine with Docker:
❯ cat Dockerfile2
FROM python:3.5 AS builder
RUN pip install virtualenv
RUN virtualenv /venv -p python3

FROM python:3.5-slim
COPY --from=builder /venv /venv

❯ docker build . -t test -f Dockerfile2
Sending build context to Docker daemon  547.8kB
Step 1/5 : FROM python:3.5 AS builder
...
Successfully built 05bc82648689
Successfully tagged test:latest

❯ docker run -it test:latest ls -als /venv
total 20
4 drwxr-xr-x 5 root root 4096 Mar 13 16:02 .
4 drwxr-xr-x 1 root root 4096 Mar 13 16:03 ..
4 drwxr-xr-x 2 root root 4096 Mar 13 15:29 bin
4 drwxr-xr-x 2 root root 4096 Mar 13 15:29 include
4 drwxr-xr-x 3 root root 4096 Mar 13 15:29 lib
@nfvs
Copy link
Author

nfvs commented Mar 13, 2019

Seems like it's an issue with .dockerignore:

DEBU[0060] /kaniko/0/venv found in .dockerignore, ignoring

I have a pretty aggressive .dockerignore that blacklists everything then whitelists individual files, which obviously doesn't include files generated in a previous stage. Maybe a copy-from-previous-stage should ignore the .dockerignore, since we usually don't want to send a local environment as context but may want to generate one and move it between stages?

@viceice
Copy link

viceice commented Mar 18, 2019

Duplicate of #595

@dlorenc
Copy link
Contributor

dlorenc commented Mar 19, 2019

Closing as a dup of #595

@dlorenc dlorenc closed this as completed Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants