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

"COPY ." not copying all files to the image #1110

Closed
alexfrancavilla opened this issue Oct 8, 2018 · 5 comments
Closed

"COPY ." not copying all files to the image #1110

alexfrancavilla opened this issue Oct 8, 2018 · 5 comments
Assignees
Labels
kind/bug Something isn't working

Comments

@alexfrancavilla
Copy link

alexfrancavilla commented Oct 8, 2018

Hi there. I've recently updated my skaffold version which broke the image building process. Usually I work with Skaffold + Minikube + Helm. The following Dockerfile line behaves differently:

COPY . ./

I've nailed it down to work with skaffold 0.10.0 and breaks with 0.11.0 (also the newest version 0.15.1 is affected for me). What happens is that the COPY task is not adding ALL files to the image but is missing some. The "some" is a little hard to describe, it is always the same files and not randomly, but is different between projects. In an extremely simple Nodejs/Express project the task only added the Dockerfile, and misses the src/ dir as well as top level config files like tsconfig.json. In another PHP project other (randomly looking) directories and files are affected.

The building process then goes on and my project will eventually fail at runtime because of missing sources or other relevant stuff.

It may be worth noting that every project for me has the skaffold.yaml file in a different directory. The node project's skaffold file is located in a separate repository (../dev/skaffold.yaml), the PHP project stores it in a subdirectory (build/skaffold.yaml).

The Dockerfile has not changed, usual docker build . commands result in the same working image as the 0.10.0 skaffold version.

My workaround is to use COPY * dest/ instead of COPY . dest/, but this obviously may skip hidden files/directories.

Information

  • Skaffold version: 0.10.0 works, 0.11.0 fails up until 0.15.1
  • Operating system: macOS 10.13.6 using Homebrew, zsh, Docker 18.06.1-ce, Minikube's Docker version is 17.12.1-ce

skaffold.yaml (0.11.0+)

apiVersion: skaffold/v1alpha3
kind: Config
build:
  artifacts:
    - imageName: api
      workspace: ../api
deploy:
  helm:
    releases:
      - name: foo-project
        chartPath: ../chart
        valuesFiles:
          - skaffold-values.yaml
        values:
          api.image: api

skaffold.yaml (0.10.0)

apiVersion: skaffold/v1alpha2
kind: Config
build:
  artifacts:
    - imageName: api
      workspace: ../api
deploy:
  helm:
    releases:
      - name: foo-project
        chartPath: ../chart
        valuesFilePath: skaffold-values.yaml
        values:
          api.image: api

Dockerfile

FROM node:10.11.0-alpine
EXPOSE 8080
WORKDIR /app

COPY package.json yarn.lock ./
RUN yarn

# This COPY breaks!
COPY . ./
RUN yarn exec tsc

CMD ["node", "dist/main.js"]

.dockerignore of the project (if that is relevant)

/.*
/Dockerfile
/node_modules/
@balopat balopat added the kind/bug Something isn't working label Oct 8, 2018
@dgageot dgageot self-assigned this Oct 8, 2018
@dgageot
Copy link
Contributor

dgageot commented Oct 8, 2018

Hi @alexfrancavilla do you think it's possible to setup a very simple project that shows the issue?

@alexfrancavilla
Copy link
Author

Hi @dgageot sure thing! I've setup a repository here: alexfrancavilla/skaffold-issue-1110, which looks equal to what I've explained above.

Steps to reproduce:

git clone [email protected]:alexfrancavilla/skaffold-issue-1110.git
cd skaffold-issue-1110/dev

# This is how things work as expected using 0.10.0
brew switch skaffold 0.10.0
skaffold dev -f skaffold-0.10.0.yaml

# And the failing run with 0.15.1 (or any other version in between)
brew switch skaffold 0.15.1
skaffold dev

tsc fails to compile because tsconfig.json and src/ are missing from the image, recognized through the displayed help text.

PS: Assuming you're running macOS and want to use homebrew switch feature, here's the 0.10.0 version:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/a6406334afa64b27cebc22d0f18b90a539415a95/Formula/skaffold.rb

Thanks for taking care!

@dgageot
Copy link
Contributor

dgageot commented Oct 8, 2018

@alexfrancavilla OK. So I reproduced the issue. I'll try to understand what's going on

@dgageot
Copy link
Contributor

dgageot commented Oct 8, 2018

It looks like it's because of the /.* in the .dockerignore. I'll take a look at how it should be interpreted and how Skaffold interprets it.

dgageot added a commit to dgageot/skaffold that referenced this issue Oct 8, 2018
@alexfrancavilla
Copy link
Author

Amazing! I've just built your fix-1110 branch and can confirm that it works perfectly. Thank you very much for your quick help.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants