-
Notifications
You must be signed in to change notification settings - Fork 769
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
Fixed kompose build failure #837
Conversation
4c4e783
to
cb82a2c
Compare
@cdrage review needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix comments, otherwise LGTM
pkg/transformer/utils.go
Outdated
if service.Dockerfile != "" { | ||
//imagePath = path.Join(relativePath, service.Build) | ||
dockerfile_dir, _ := path.Split(service.Dockerfile) | ||
//imagePath = path.Join(imagePath, dockerfile_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented out lines
pkg/transformer/utils.go
Outdated
var imagePath string | ||
if service.Dockerfile != "" { | ||
//imagePath = path.Join(relativePath, service.Build) | ||
dockerfile_dir, _ := path.Split(service.Dockerfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not correct variable name, use dockerfileDir
cb82a2c
to
7dac78e
Compare
@cdrage changed variable name, good to go |
Hey @surajd can you do a quick review to see if this closes your issue? Ideally... one day we'll have some integration tests for build... |
sorry for the late reply, it didn't work for me: $ kompose version
1.3.0 (7dac78e)
$ docker version
Client:
Version: 17.09.0-ce
API version: 1.32
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:42:30 2017
OS/Arch: linux/amd64
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:43:51 2017
OS/Arch: linux/amd64
Experimental: false trying to build using kompose $ kompose up -v
DEBU Docker Compose version: 2
DEBU Opening compose files: docker-compose.yml
DEBU [0/1] [gen]: Adding
DEBU [0/1] [default]: EventType: 32
DEBU Default network found
INFO Build key detected. Attempting to build and push image 'surajd/kedgeschema'
DEBU Compose file dir: /home/fedora/go/src/github.com/kedgeproject/json-schema-generator
INFO Building image 'surajd/kedgeschema' from directory 'scripts'
DEBU Created temporary file /tmp/kompose-image-build-681917583 for Docker image tarballing
FATA Error while deploying application: k.Transform failed: Unable to build Docker image for service gen: Unable to build image. For more output, use -v or --verbose when converting.: The command '/bin/sh -c cd /go/src/github.com/kedgeproject/kedge-jsonschema && go build -o kedge-jsonschema main.go parsego.go' returned a non-zero code: 1 works with docker cli $ docker build -t surajd/kedgeschema -f ./scripts/Dockerfile .
Sending build context to Docker daemon 40.92MB
Step 1/11 : FROM golang:1.9.0 AS build-env
---> 1cdc81f11b10
Step 2/11 : ADD . /go/src/github.com/kedgeproject/kedge-jsonschema
---> 08dc2baeca36
Step 3/11 : RUN cd /go/src/github.com/kedgeproject/kedge-jsonschema && go build -o kedge-jsonschema main.go parsego.go
---> Running in 0c0a2eb954bc
---> 4159167cb457
Removing intermediate container 0c0a2eb954bc
Step 4/11 : FROM garethr/openapi2jsonschema
---> a889e74d0c7b
Step 5/11 : RUN apk add --update curl && rm -rf /var/cache/apk/*
---> Running in e0b9df79e429
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/3) Installing libssh2 (1.7.0-r0)
(2/3) Installing libcurl (7.55.0-r0)
(3/3) Installing curl (7.55.0-r0)
Executing busybox-1.24.2-r13.trigger
OK: 32 MiB in 35 packages
---> e1c4f68be0f3
Removing intermediate container e0b9df79e429
Step 6/11 : RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
---> Running in a687d92837ba
---> c87a0b8a94ee
Removing intermediate container a687d92837ba
Step 7/11 : COPY --from=build-env /go/src/github.com/kedgeproject/kedge-jsonschema/kedge-jsonschema /usr/local/bin/
---> ebeb9c27eca1
Step 8/11 : COPY ./scripts/entrypoint.sh /usr/local/bin/
---> 879a1dbeeb42
Step 9/11 : WORKDIR /data
---> 01e4d1e6444e
Removing intermediate container e7f7c96fe212
Step 10/11 : ENTRYPOINT
---> Running in d822bde63994
---> 0ee419b4a177
Removing intermediate container d822bde63994
Step 11/11 : CMD /bin/sh /usr/local/bin/entrypoint.sh
---> Running in fbf29bf08841
---> 74e63cef9742
Removing intermediate container fbf29bf08841
Successfully built 74e63cef9742
Successfully tagged surajd/kedgeschema:latest |
@surajssd , problem with context and build has been solved with this PR, as you can see logs problem is with line in Dockerfile
|
We really need to add tests for this, I believe we should add some integration tests with this too... |
7dac78e
to
b4830e6
Compare
We don't need docker login... We can build these locally.
…On Nov 8, 2017 03:32, "Suraj Narwade" ***@***.***> wrote:
@cdrage <https://github.com/cdrage> @surajssd
<https://github.com/surajssd> since we need docker login, as of now we
don't have integration tests for such cases
cc @ashetty1 <https://github.com/ashetty1>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#837 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGH-oBeff12WgGZxPslTuNprtQ0MuFzUks5s0WcXgaJpZM4PvYa6>
.
|
b4830e6
to
cb5ed97
Compare
@surajssd @cdrage it seems, error is coming from |
pkg/transformer/utils.go
Outdated
var imagePath string | ||
if service.Dockerfile != "" { | ||
dockerfileDir, _ := path.Split(service.Dockerfile) | ||
imagePath = path.Join(relativePath, service.Build, dockerfileDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right fix. imagePath
is context
. You need to modify your BuildImage
function to support specifying the Dockerfile location, because the docker daemon needs the whole thing in a tar package along with the parameter that specifies where to find the Dockerfile inside the package.
One possible fix: https://github.com/fsouza/kompose/pull/1 (this is probably too hacky to be merged as-is and I didn't really look into the tests).
If you want to test this locally (assuming you have kompose cloned inside your $GOPATH
):
% cd $GOPATH/src/github.com/kubernetes/kompose
% curl https://patch-diff.githubusercontent.com/raw/fsouza/kompose/pull/1.diff | patch -p1
% go install
This will give you the fixed kompose, and you can use it to build the images locally:
% cd $GOPATH/src/github.com/kedgeproject/json-schema-generator
% cat docker-compose.yml
version: "2"
services:
my-service:
build:
context: .
dockerfile: scripts/Dockerfile
image: docker.io/fsouza/kompose-example
% kompose up -v
DEBU Docker Compose version: 2
DEBU Opening compose files: docker-compose.yml
DEBU [0/1] [my-service]: Adding
DEBU [0/1] [default]: EventType: 32
DEBU Default network found
INFO Build key detected. Attempting to build and push image 'docker.io/fsouza/kompose-example'
DEBU Compose file dir: /Users/fsouza/src/github.com/kedgeproject/json-schema-generator
INFO Building image 'docker.io/fsouza/kompose-example' from directory 'json-schema-generator'
DEBU Created temporary file /tmp/kompose-image-build-068813155 for Docker image tarballing
INFO Image 'docker.io/fsouza/kompose-example' from directory 'json-schema-generator' built successfully
DEBU Image docker.io/fsouza/kompose-example build output:
[ omitting pull output]
Status: Downloaded newer image for garethr/openapi2jsonschema:latest
---> a889e74d0c7b
Step 5/11 : RUN apk add --update curl && rm -rf /var/cache/apk/*
---> Running in 9550de763469
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/3) Installing libssh2 (1.7.0-r0)
(2/3) Installing libcurl (7.55.0-r2)
(3/3) Installing curl (7.55.0-r2)
Executing busybox-1.24.2-r13.trigger
OK: 32 MiB in 35 packages
Removing intermediate container 9550de763469
---> 0581d5f0334b
Step 6/11 : RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
---> Running in 614e1a2f354d
Removing intermediate container 614e1a2f354d
---> ce00b0eca38b
Step 7/11 : COPY --from=build-env /go/bin/schemagen /usr/local/bin/
---> 8a10cbb79e51
Step 8/11 : COPY ./scripts/entrypoint.sh /usr/local/bin/
---> f724b972bbd9
Step 9/11 : WORKDIR /data
Removing intermediate container 4641e6f13a49
---> 76ef64fb903b
Step 10/11 : ENTRYPOINT []
---> Running in 7a646cbf785c
Removing intermediate container 7a646cbf785c
---> 52de1720118a
Step 11/11 : CMD ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
---> Running in 12da818ac4f0
Removing intermediate container 12da818ac4f0
---> 761f958cfea5
Successfully built 761f958cfea5
Successfully tagged fsouza/kompose-example:latest
[ omit push ]
(The built image is actually on Docker Hub under fsouza/kompose-example
)
Thanks a lot @fsouza for clearing out the confusion, I will update PR accordingly |
01000c9
to
ec4e92c
Compare
ec4e92c
to
693877e
Compare
While `local` build, kompose was not recognizing `dockerfile` key Hence it was breaking the build as mentioned in issue kubernetes#832. This PR will fix the issue.
693877e
to
286fbd1
Compare
I am using this file in https://github.com/kedgeproject/json-schema-generator $ cat docker-compose.yml
version: "2"
services:
gen:
build:
context: .
dockerfile: scripts/Dockerfile
image: surajd/testschema When I run kompose I get error: $ kompose up -v
DEBU Docker Compose version: 2
DEBU Opening compose files: docker-compose.yml
DEBU [0/1] [gen]: Adding
DEBU [0/1] [default]: EventType: 32
DEBU Default network found
INFO Build key detected. Attempting to build and push image 'surajd/testschema'
DEBU Compose file dir: /home/hummer/go/src/github.com/kedgeproject/json-schema-generator
INFO Building image 'surajd/testschema' from directory 'json-schema-generator'
DEBU Created temporary file /tmp/kompose-image-build-720868890 for Docker image tarballing
FATA Error while deploying application: k.Transform failed: Unable to build Docker image for service gen: Unable to build image.
For more output, use -v or --verbose when converting.: API error (500): {"message":"Cannot locate specified Dockerfile: Dockerfile"} I am not sure if it is taking the Dockerfile which is somewhere else and the context is somewhere else. I think you might want to run this test to test if the code works. |
@surajssd , can you please check one more time,
and output is:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM!
LGTM 👍 |
Hello, anybody still here for some help. IO ma stuck as i ma getting similar error.
Server: |
@CzarMich |
Hello @hangyan. thanks for the quick reply. Does that mean that provided I have Kompose installed, i can use Kubectl to create resources that were packaged for Docker with docker compose; Like for my case I have 3 files (docker-compose; xd1, xx1) Thanks |
While
local
build, kompose was not recognizingdockerfile
keyHence it was breaking the build as mentioned in issue #832.
This PR will fix the issue.