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

skaffold build fails if the artifact context is a substring of Docker #4243

Closed
sujit-kamireddy opened this issue May 21, 2020 · 2 comments · Fixed by #4260
Closed

skaffold build fails if the artifact context is a substring of Docker #4243

sujit-kamireddy opened this issue May 21, 2020 · 2 comments · Fixed by #4260
Assignees
Labels
area/build build/docker kind/bug Something isn't working priority/p0 Highest priority. We are actively looking at delivering it.

Comments

@sujit-kamireddy
Copy link

  • I have a simple hello-world app with a Dockerfile in a folder named 'Dock', directly under root directory. e.g. ${workspaceFolder}/Dock/Dockerfile

Expected behavior

When I run skaffold build --filename skaffold.yaml, build should pass.

Actual behavior

Getting the below error. It seems skaffold is looking for the Dockerfile at the wrong location (in the root folder as opposed to ${workspaceFolder}/Dock.

error checking cache, caching may not work as expected:
getting hash for artifact gcr.io/sujit-project/nodejs-cloud-run-hello-world-13:
getting dependencies for "gcr.io/sujit-project/nodejs-cloud-run-hello-world-13":
opening dockerfile "/Users/sujitr/cloudcode-projects/nodejs-cloud-run-hello-world-13/Dockerfile":
open /Users/sujitr/cloudcode-projects/nodejs-cloud-run-hello-world-13/Dockerfile: no such file or directory" ,
time="2020-05-21T11:05:48-07:00" level=fatal
msg="build failed: building [gcr.io/sujit-project/nodejs-cloud-run-hello-world-13]:
build artifact: docker build: error during connect: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.40/build?buildargs=null&cachefrom=null&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=null&memory=0&memswap=0&networkmode=&rm=0&shmsize=0&t=gcr.io%2Fsujit-project%2Fnodejs-cloud-run-hello-world-13%3Alatest&target=&ulimits=null&version=":
creating docker context:
getting relative tar paths:
opening dockerfile "/Users/sujitr/cloudcode-projects/nodejs-cloud-run-hello-world-13/Dockerfile":
open /Users/sujitr/cloudcode-projects/nodejs-cloud-run-hello-world-13/Dockerfile: no such file or directory"

Information

  • Skaffold version: version...
  • Operating system: mac
  • Contents of skaffold.yaml:
apiVersion: skaffold/v2beta1
kind: Config
metadata:
  name: nodejs-cloud-run-hello-world--
build:
  artifacts:
    - image: nodejs-cloud-run-hello-world-13
      context: Dock
  tagPolicy:
    sha256: {}
  local:
    push: true
deploy:
  statusCheckDeadlineSeconds: 300

Steps to reproduce the behavior

  1. create a new nodejs hello-world app from cloud code - cloud run template. https://github.com/GoogleCloudPlatform/cloud-code-samples/tree/master/nodejs/nodejs-cloud-run-hello-world
  2. Move the Dockerfile to a directory named Dock.
  3. Add a skaffold.yaml file with the above contents
  4. Run skaffold build --filename skaffold.yaml
@tstromberg tstromberg added kind/bug Something isn't working needs-reproduction needs reproduction from the maintainers to validate the issue is truly a skaffold bug triage/discuss Items for discussion labels May 21, 2020
@tstromberg
Copy link
Contributor

This sounds very very unusual. Good find!

@briandealwis
Copy link
Member

Aha: the culprit is line 38:

func NormalizeDockerfilePath(context, dockerfile string) (string, error) {
if filepath.IsAbs(dockerfile) {
return dockerfile, nil
}
if !strings.HasPrefix(dockerfile, context) {
dockerfile = filepath.Join(context, dockerfile)
}
return filepath.Abs(dockerfile)
}

This code is trying to be too clever. I'm not sure allowing an absolute path is a good thing in the first place.

@briandealwis briandealwis self-assigned this May 26, 2020
@briandealwis briandealwis added area/build build/docker priority/p0 Highest priority. We are actively looking at delivering it. and removed needs-reproduction needs reproduction from the maintainers to validate the issue is truly a skaffold bug triage/discuss Items for discussion labels May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build build/docker kind/bug Something isn't working priority/p0 Highest priority. We are actively looking at delivering it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants