openshift / source-to-image

A tool for building artifacts from source and injecting into container images
Apache License 2.0
2.47k stars 698 forks source link

Can't call the assemble script when providing the scripts url using -s option #82

Closed iocanel closed 10 years ago

iocanel commented 10 years ago

I am trying to use the sti and provide a url to the sti scripts as follows:

sti build https://github.com/iocanel/test-sti.git fabric8/karaf-2.4 fabric8/test-sti -s file:/somepath/.sti/bin

The error I am getting is:

/bin/bash: assemble: No such file or directory An error occured: Container exited with exit code: 127

soltysh commented 10 years ago

@iocanel you should be using file://somepath/.sti/bin (double slash after file:) since we're matching based on the golang's url scheme. See https://github.com/openshift/source-to-image/blob/master/pkg/sti/util/download.go#L78 for details.

iocanel commented 10 years ago

@soltysh Thanks for the very quick response.

The files do get uploaded or at least they seem to get uploaded even with a single slash. Using double slashes, I get an upload error: "An error occured: Scripts download failed". Using tipple slashes, I get the same error I do when using single slash.

bparees commented 10 years ago

and file:/somepath/.sti/bin contains an assemble script?

iocanel commented 10 years ago

Yes.

From what I understand the script does get uploaded to the container. The error "/bin/bash: assemble: No such file or directory" is thrown when trying to execute it.

soltysh commented 10 years ago

Could you provide us with full build log, invoke sti with --verbose and please attach it here. It'll help us debug the problem you're experiencing. If it's possible attach the sti scripts you're using as well.

iocanel commented 10 years ago

Here's the verbose output:

2014/11/14 00:20:37 Using docker socket: tcp://dockerhost:2375 2014/11/14 00:20:37 Downloaded 'file:///tmp/.sti/bin//assemble' 2014/11/14 00:20:37 Downloaded 'file:///tmp/.sti/bin//run' 2014/11/14 00:20:37 Image fabric8/karaf-2.4 available locally 2014/11/14 00:20:37 Image contains default script url '' 2014/11/14 00:20:37 Looking for assemble script at /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/downloads/scripts/assemble 2014/11/14 00:20:37 Found assemble script from user provided url. 2014/11/14 00:20:37 Looking for run script at /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/downloads/scripts/run 2014/11/14 00:20:37 Found run script from user provided url. 2014/11/14 00:20:37 Downloaded 'file:///tmp/.sti/bin//save-artifacts' 2014/11/14 00:20:37 Image fabric8/karaf-2.4 available locally 2014/11/14 00:20:37 Image contains default script url '' 2014/11/14 00:20:37 Looking for save-artifacts script at /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/downloads/scripts/save-artifacts 2014/11/14 00:20:37 Found save-artifacts script from user provided url. 2014/11/14 00:20:37 Clean build will be performed 2014/11/14 00:20:37 Performing source build from https://github.com/iocanel/test-sti.git 2014/11/14 00:20:37 Downloading https://github.com/iocanel/test-sti.git to directory /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src Cloning into '/var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src'... remote: Counting objects: 38, done. remote: Total 38 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (38/38), done. Checking connectivity... done. 2014/11/14 00:20:39 Using image name fabric8/karaf-2.4 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/scripts/assemble as scripts/assemble 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/scripts/run as scripts/run 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/scripts/save-artifacts as scripts/save-artifacts 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/.gitignore as src/.gitignore 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/.sti/bin/assemble as src/.sti/bin/assemble 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/.sti/bin/run as src/.sti/bin/run 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/.sti/bin/save-artifacts as src/.sti/bin/save-artifacts 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/pom.xml as src/pom.xml 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/src/main/fabric8/assembly.xml as src/src/main/fabric8/assembly.xml 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/src/main/fabric8/data/order1.xml as src/src/main/fabric8/data/order1.xml 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/src/main/fabric8/data/order2.xml as src/src/main/fabric8/data/order2.xml 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/src/main/fabric8/data/order3.xml as src/src/main/fabric8/data/order3.xml 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/src/main/fabric8/data/order4.xml as src/src/main/fabric8/data/order4.xml 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/src/main/fabric8/data/order5.xml as src/src/main/fabric8/data/order5.xml 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/src/main/fabric8/features.xml as src/src/main/fabric8/features.xml 2014/11/14 00:20:39 Adding to tar: /var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253/upload/src/src/main/resources/OSGI-INF/blueprint/cbr.xml as src/src/main/resources/OSGI-INF/blueprint/cbr.xml 2014/11/14 00:20:39 Image fabric8/karaf-2.4 available locally 2014/11/14 00:20:39 Creating container using config: {Hostname: Domainname: User: Memory:0 MemorySwap:0 CpuShares:0 CpuSet: AttachStdin:false AttachStdout:true AttachStderr:false PortSpecs:[] ExposedPorts:map[] Tty:false OpenStdin:true StdinOnce:true Env:[] Cmd:[/bin/bash assemble] Dns:[] Image:fabric8/karaf-2.4 Volumes:map[] VolumesFrom: WorkingDir: Entrypoint:[] NetworkDisabled:false} 2014/11/14 00:20:39 Attaching to container 2014/11/14 00:20:39 Starting container 2014/11/14 00:20:39 Waiting for container /bin/bash: assemble: No such file or directory 2014/11/14 00:20:39 Container exited 2014/11/14 00:20:39 Removing directory '/var/folders/zw/h58c2fb16jl4w0kp8jttlh5w0000gn/T/sti621297253' An error occured: Container exited with exit code: 127

iocanel commented 10 years ago

The sti scripts look like this: https://github.com/iocanel/test-sti/tree/master/.sti/bin and are still work in progress.

By the way, since I have them under .sti/bin in my git repo, shouldn't they be used if I don't specify any URL?

bparees commented 10 years ago

where's the dockerfile for your image?

@soltysh I think the issue here is the scripts aren't handling+untarring the tar stream. Seems like maybe our docs need work?

iocanel commented 10 years ago

The docker file is based on https://registry.hub.docker.com/u/fabric8/karaf-2.4/dockerfile/ with minor local modifications.

I also tried the openshift/wildfly-8-centos image and didn't had much luck either. The main difference when used the wildly image is that the command that is sent to docker is "./bin/sh -c usage assemble". It then just displays the usage message and doesn't seem to execute assemble.

iocanel commented 10 years ago

I found the pull request and copied the "sti-helper" script into my image. Now it seems that its able to execute the assemble script when passed both from command line using the -s option and by specifying a remote URL into the base image.

Now I need to check if my assemble script can find the sources and build them.

soltysh commented 10 years ago

The wildfly image have a pending PR that @bparees will merge (https://github.com/openshift/wildfly-8-centos/pull/25). I'll be working on the docs for the STI to be more helpful as well. I'll also have a closer look at your output later today, so any input you get in the meantime are very appreciated. Anyway thanks for your input and commitment :+1:

iocanel commented 10 years ago

Yeah, that the PR I copied the sti-helper from.

I thank you for the quick feedback and support :-)

bparees commented 10 years ago

fyi, PR has been merged.

soltysh commented 10 years ago

@iocanel from your last comment I'm assuming it worked, right? Can we then close this issue?

iocanel commented 10 years ago

Yes it worked. I'd close the issue myself but thought you may wanted to keep it open until the doc gets updated.

soltysh commented 10 years ago

I have a trello for that one (https://trello.com/c/PhR9r79D/395-3-support-sti-scripts-in-image) and I'm going to handle that one in this upcoming sprint, so I think it's ok to close it.