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

oq does not work in a docker container #39

Closed
sundipnair opened this issue Nov 4, 2019 · 15 comments · Fixed by #44
Closed

oq does not work in a docker container #39

sundipnair opened this issue Nov 4, 2019 · 15 comments · Fixed by #44
Labels
kind:bug An existing feature isn't doing something correctly kind:infrastructure
Milestone

Comments

@sundipnair
Copy link

sundipnair commented Nov 4, 2019

I have build a docker container like so

FROM crystallang/crystal:latest

RUN git clone https://github.com/Blacksmoke16/oq.git
WORKDIR /oq
RUN shards build --production
RUN chmod +x /oq/bin/oq
RUN cp /oq/bin/oq /bin/

ENV PATH /bin/:$PATH

RUN oq --help


I get an error when running oq --help

Sending build context to Docker daemon 5.632kB
Step 1/8 : FROM crystallang/crystal:latest
---> e9906ad8c49f
Step 2/8 : RUN git clone https://github.com/Blacksmoke16/oq.git
---> Using cache
---> 9989d5d29ddb
Step 3/8 : WORKDIR /oq
---> Using cache
---> 9a3f277c8558
Step 4/8 : RUN shards build --production
---> Using cache
---> 1ed78db07894
Step 5/8 : RUN chmod +x /oq/bin/oq
---> Using cache
---> 0ebaf7c94a18
Step 6/8 : RUN cp /oq/bin/oq /bin/
---> Using cache
---> e02d9d996fff
Step 7/8 : ENV PATH /bin/:$PATH
---> Using cache
---> 6bc2e585cc6e
Step 8/8 : RUN oq --help
---> Running in d0822a0f3af4
Failed to raise an exception: END_OF_STACK
[0x490bb6] *CallStack::print_backtrace:Int32 +118
[0x46d466] __crystal_raise +86
[0x46d98e] ???
[0x4bbab6] *Crystal::System::File::open<String, String, File::Permissions>:Int32 +214
[0x4b7ec3] *File::new<String, String, File::Permissions, Nil, Nil>:File +67
[0x48785d] *CallStack::read_dwarf_sections:(Array(Tuple(UInt64, UInt64, String)) | Nil) +109
[0x4875ed] *CallStack::decode_line_number:Tuple(String, Int32, Int32) +45
[0x486d78] *CallStack#decode_backtrace:Array(String) +296
[0x486c32] *CallStack#printable_backtrace:Array(String) +50
[0x4f049d] *Exception+ +77
[0x4f02e8] *Exception+ +120
[0x4ec07a] *AtExitHandlers::run:Int32 +490
[0x55510b] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +139
[0x477e76] main +6
[0x7f0eb572e830] __libc_start_main +240
[0x46ba19] _start +41
[0x0] ???
The command '/bin/sh -c oq --help' returned a non-zero code: 5


Please can you help identify the issue. Thanks.

@Blacksmoke16 Blacksmoke16 added the kind:bug An existing feature isn't doing something correctly label Nov 4, 2019
@Blacksmoke16
Copy link
Owner

Blacksmoke16 commented Nov 4, 2019

@sundipnair Is there any reason you're wanting to build the binary from source versus just copying the binary from the latest release into the image?

I'm thinking this is some sort of Crystal issue. I would try just using a prebuilt binary within your image.

FROM crystallang/crystal:latest

RUN apt update && apt install -y jq

COPY ./oq /bin/oq
RUN chmod +x /bin/oq
RUN /bin/oq --help

Seems to work fine, and probably would be the more ideal way. I'll keep this open until the Crystal issue is fixed.

@sundipnair
Copy link
Author

sundipnair commented Nov 4, 2019

thanks for your reply.

so where do you find the ./oq?

I get an error

Step 3/5 : COPY ./oq /bin/oq
COPY failed: stat /var/lib/docker/tmp/docker-builder017445899/oq: no such file or directory

@Blacksmoke16
Copy link
Owner

Oh sorry. I got it from the latest release assets https://github.com/Blacksmoke16/oq/releases/tag/v0.2.1. Then renamed it from oq-0.2.1-linux-x86_64 to oq.

@sundipnair
Copy link
Author

thanks. that builds the image alright.

however running oq gives the following error

cat template.yml | oq -o json -i yaml
jq - commandline JSON processor [version 1.5-1-a5b5cbe]
Usage: jq [options] [file...]

jq is a tool for processing JSON inputs, applying the
given filter to its JSON text inputs and producing the
filter's results as JSON on standard output.
The simplest filter is ., which is the identity filter,
copying jq's input to its output unmodified (except for
formatting).
For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq

Some of the options include:
 -c		compact instead of pretty-printed output;
 -n		use `null` as the single input value;
 -e		set the exit status code based on the output;
 -s		read (slurp) all inputs into an array; apply filter to it;
 -r		output raw strings, not JSON texts;
 -R		read raw strings, not JSON texts;
 -C		colorize JSON;
 -M		monochrome (don't colorize JSON);
 -S		sort keys of objects on output;
 --tab	use tabs for indentation;
 --arg a v	set variable $a to value <v>;
 --argjson a v	set variable $a to JSON value <v>;
 --slurpfile a f	set variable $a to an array of JSON texts read from <f>;
See the manpage for more options.

@Blacksmoke16
Copy link
Owner

Blacksmoke16 commented Nov 4, 2019

Need to provide the jq filter to use.

Try cat template.yml | oq -i yaml .

Where in this case the . is the filter. The filter can also be in a file using jq's -f filter_file option.

@sundipnair
Copy link
Author

Thanks ..

@sundipnair
Copy link
Author

@Blacksmoke16 , I have added some instuctions to the read me to craete a docker container. I have pushed a branch called docker_install_instrcution. how do I get this PR'd.

@Blacksmoke16
Copy link
Owner

https://github.com/Blacksmoke16/oq#contributing Would be the thing to reference. Should just be able to make it from your fork to this repo.

@Blacksmoke16
Copy link
Owner

Blacksmoke16 commented Nov 5, 2019

@sundipnair Actually after thinking about this more; I think it would be better to just actually create an image and have it available to use, versus just documenting how to do that. (Or at least also mention how to include oq into an existing image).

I can take care of this, don't think it 'll be too hard.

@sundipnair
Copy link
Author

sundipnair commented Nov 5, 2019 via email

@Blacksmoke16 Blacksmoke16 added this to the 1.1.0 milestone Dec 16, 2019
@Blacksmoke16
Copy link
Owner

Blacksmoke16 commented Dec 28, 2019

@sundipnair I pushed an image that includes the static oq from 1.0.0 in an Alpine image. Does that suit your needs?

I'll also add a section to the readme on using oq within another image.

EDIT: See my latest comment.

@sundipnair
Copy link
Author

sundipnair commented Dec 28, 2019

@Blacksmoke16 , Good one. I was able to build my own image and work with that ...

I will play with your container for some of my personal stuff and see how it goes.

Might be worth adding the docker link on the Readme file.

@Blacksmoke16
Copy link
Owner

Blacksmoke16 commented Dec 28, 2019

Actually, @sundipnair what is your use case for needing oq in a docker image versus just downloading the binary onto your OS?

The binary on Github is statically linked so at this point the image isn't doing much more than installing jq and wrapping a binary.

EDIT: Er, I assume you really just want to get oq into an image you're building yourself?

@sundipnair
Copy link
Author

sundipnair commented Dec 29, 2019

@Blacksmoke16 , Just wanted to dynamically edit a yaml as part of a ci/cd step. So needed oq in an image that can be used within the pipeline.

@Blacksmoke16
Copy link
Owner

Blacksmoke16 commented Dec 29, 2019

👍 Perfect, https://github.com/Blacksmoke16/oq#docker should cover how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug An existing feature isn't doing something correctly kind:infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants