From 7dac78e1ed46963e7e6593976d5c624ba90848c4 Mon Sep 17 00:00:00 2001 From: Suraj Narwade Date: Thu, 28 Sep 2017 14:01:52 +0530 Subject: [PATCH] Fixed kompose build failure While `local` build, kompose was not recognizing `dockerfile` key Hence it was breaking the build as mentioned in issue #832. This PR will fix the issue. --- pkg/transformer/utils.go | 9 ++++++++- .../fixtures/buildconfig/docker-compose-dockerfile.yml | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 script/test/fixtures/buildconfig/docker-compose-dockerfile.yml diff --git a/pkg/transformer/utils.go b/pkg/transformer/utils.go index 089374057b..cae4196151 100644 --- a/pkg/transformer/utils.go +++ b/pkg/transformer/utils.go @@ -210,7 +210,14 @@ func BuildDockerImage(service kobject.ServiceConfig, name string, relativePath s // Get the appropriate image source and name // use path.Base to get the last element of the relative build path - imagePath := path.Join(relativePath, path.Base(service.Build)) + var imagePath string + if service.Dockerfile != "" { + dockerfileDir, _ := path.Split(service.Dockerfile) + imagePath = path.Join(relativePath, service.Build, dockerfileDir) + } else { + imagePath = path.Join(relativePath, service.Build) + } + imageName := name if service.Image != "" { imageName = service.Image diff --git a/script/test/fixtures/buildconfig/docker-compose-dockerfile.yml b/script/test/fixtures/buildconfig/docker-compose-dockerfile.yml new file mode 100644 index 0000000000..1ea177c0bf --- /dev/null +++ b/script/test/fixtures/buildconfig/docker-compose-dockerfile.yml @@ -0,0 +1,8 @@ +version: "2" + +services: + foo: + build: + context: . + dockerfile: build/Dockerfile + image: docker.io/cdrage/foobar