Skip to content

Bug: dockerfilePath does not allow a path to a parent directory #336

@lizardruss

Description

@lizardruss

What happened?
The latest version does not allow a docker file that is in a parent directory. Previous versions were able to resolve the Dockerfile from this configuration:

images:
  default:
    name: default-image
    registry: internal
    build:
      contextPath: ../../
      dockerfilePath: ../../Dockerfile
      options:
        target: default-image

With the 2.1.0 release, this configuration results in the following error:

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/covexo/devspace/pkg/devspace/image.shouldRebuild(0xc4208fe840, 0xc4214517a0, 0xc42043b8c0, 0x36, 0x1, 0x0)
        /Users/travis/gopath/src/github.com/covexo/devspace/pkg/devspace/image/build.go:235 +0x39c
github.com/covexo/devspace/pkg/devspace/image.Build(0xc421362870, 0xc4208fe840, 0xc4214960a6, 0x7, 0xc4214517a0, 0xc42159fb01, 0x59bc020, 0x68df7e0, 0xc4208fe840, 0x0, ...)
        /Users/travis/gopath/src/github.com/covexo/devspace/pkg/devspace/image/build.go:76 +0x164
github.com/covexo/devspace/pkg/devspace/image.BuildAll(0xc421362870, 0xc4208fe840, 0x1, 0x59bc020, 0x68df7e0, 0xc421449d40, 0xc421007ad0, 0xc421007ad0)
        /Users/travis/gopath/src/github.com/covexo/devspace/pkg/devspace/image/build.go:36 +0x1ef
github.com/covexo/devspace/cmd.(*UpCmd).buildAndDeploy(0xc4203b6cb0)
        /Users/travis/gopath/src/github.com/covexo/devspace/cmd/up.go:169 +0x106
github.com/covexo/devspace/cmd.(*UpCmd).Run(0xc4203b6cb0, 0xc420feaa00, 0xc421462190, 0x0, 0x1)
        /Users/travis/gopath/src/github.com/covexo/devspace/cmd/up.go:151 +0x2e3
github.com/covexo/devspace/cmd.(*UpCmd).Run-fm(0xc420feaa00, 0xc421462190, 0x0, 0x1)
        /Users/travis/gopath/src/github.com/covexo/devspace/cmd/up.go:81 +0x52
github.com/covexo/devspace/vendor/github.com/spf13/cobra.(*Command).execute(0xc420feaa00, 0xc421462180,0x1, 0x1, 0xc420feaa00, 0xc421462180)
        /Users/travis/gopath/src/github.com/covexo/devspace/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/covexo/devspace/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x68efae0, 0x0, 0x0, 0x0)
        /Users/travis/gopath/src/github.com/covexo/devspace/vendor/github.com/spf13/cobra/command.go:852 +0x30a
github.com/covexo/devspace/vendor/github.com/spf13/cobra.(*Command).Execute(0x68efae0, 0x0, 0x0)
        /Users/travis/gopath/src/github.com/covexo/devspace/vendor/github.com/spf13/cobra/command.go:800 +0x2b
github.com/covexo/devspace/cmd.Execute()
        /Users/travis/gopath/src/github.com/covexo/devspace/cmd/root.go:39 +0x91
main.main()
        /Users/travis/gopath/src/github.com/covexo/devspace/main.go:16 +0x3e

What did you expect to happen instead?
I expected the image to build and deploy successfully

How can we reproduce the bug? (as minimally and precisely as possible)
Use a relative path to a Dockerfile in a parent directory in the image build configuration

Local Environment:

  • Operating System: mac
  • Deployment method: helm

Kubernetes Cluster:

  • Cloud Provider: minikube
  • Kubernetes Version: [use kubectl version]
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.2", GitCommit:"5fa2db2bd46ac79e5e00a4e6ed24191080aa463b", GitTreeState:"clean", BuildDate:"2018-01-18T21:12:46Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.5", GitCommit:"32ac1c9073b132b8ba18aa830f46b77dcceb0723", GitTreeState:"clean", BuildDate:"2018-06-21T11:34:22Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

Anything else we need to know?
First, y'all rock, and thanks for the awesome tool!

There's a good reason for using a parent Dockerfile. My team is using lerna, which is a monorepo tool for Node.js. It allows multiple closely-related node projects to be developed together easily. It works by symlinking the projects together so that changes in one project can be picked up by another.

In order to build a docker image for each project, it was necessary to allow them to be symlinked together during the image builds to avoid going through the entire release process. The solution we arrived at was to use a multi-stage build to build a docker image for each application, while taking advantage of layer caching.

This set up worked great until dockerfilePath and contextPath stopped working in the latest release.

/kind bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/building-imagesIssues related to building Docker imageskind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions