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

Running dredd itself and hook server in separate docker containers #748

Closed
honzatrtik opened this Issue Mar 9, 2017 · 10 comments

Comments

Projects
None yet
5 participants
@honzatrtik
Copy link

honzatrtik commented Mar 9, 2017

Hi, first of all, thanks for dredd, it is great tool!

Im trying to start my hook tcp server in separate docker container and then run dredd tool itself in another container and link them together. The motivation is that I need to bootstrap our app in hook file, create some fixtures etc. but dont want to bloat our production image with dredd.
My idea was something like:

docker run -d --network dredd --name hook-server my-app-image php start-server.php hooks.php  --listen "0.0.0.0" --port 61321
docker run --rm --network dredd -v "/blueprint.apib:/blueprint.apib"--name dredd dred-image dredd /blueprint.apib http://api --hooks-worker-handler-port 61321 --hooks-worker-handler-host hook-server

Is something like this supposed to work? Im not sure, if hook server must be started by dredd itself...

Thanks in advance!

@w-vi

This comment has been minimized.

Copy link
Member

w-vi commented Mar 9, 2017

At the moment the hook server is started by dredd but you can at least in theory pass dredd the custom hook handler command in your case the docker run <your hook server> and dredd will start it. I haven't tried it myself yet but was thinking along these lines. I am happy to help you get this setup running.

@w-vi

This comment has been minimized.

Copy link
Member

w-vi commented Mar 9, 2017

@honzatrtik

This comment has been minimized.

Copy link

honzatrtik commented Mar 9, 2017

but you can at least in theory pass dredd the custom hook handler command in your case the docker run

Im afraid, this is not possible, because you can not run docker container inside docker container (it is actually possible but not in our case), anyway - maybe I can try to pass some dummy command, which will output string "Starting"... I will try and lat you know.
Thanks for the answer!

@w-vi

This comment has been minimized.

Copy link
Member

w-vi commented Mar 9, 2017

I see, In that case I'd just put some script which would run and stop on SIGTERM, something along these lines should suffice.

#!/bin/bash
function term() {
    echo 'Caught SIGTERM, exiting.'
    exit 0
}

trap 'term' SIGTERM

while true
do
   sleep 1
done
@w-vi

This comment has been minimized.

Copy link
Member

w-vi commented Mar 9, 2017

Look at the default values of all the related to hook handlers settings so that you listen on correct port and so on http://dredd.readthedocs.io/en/latest/usage-cli/#-hooks-worker-after-connect-wait

@honzajavorek

This comment has been minimized.

Copy link
Member

honzajavorek commented Mar 15, 2017

@honzatrtik What @w-vi wrote you is exactly what we do in tests. We use dummy script (e.g. this) as a value for the --language option, so Dredd thinks it's been able to successfully start/run/terminate a hook handler, and then we run a mock hook handler for testing purposes on hook handler port.

So this should work perfectly. Feed Dredd with dummy script and expose the hook handler on correct port. You will just need to start and stop the hook handler yourself.

I'll close this as solved, but please come back and comment in case it doesn't work, so we can re-open and find a solution 🙂 And thanks for using Dredd and for bringing this up! 👍

@TotempaaltJ

This comment has been minimized.

Copy link

TotempaaltJ commented Mar 20, 2017

Hey, it'd be super sweet if there was a native solution for this. We're running into this as well now. Maybe null could be an argument to language? The spawnHandler and terminateHandler calls could just be bypassed in that case.

It seems kind of pointless to have the whole handler host/port configuration if Dredd then wants to set it up itself anyway, right?

I was about to create a different issue for this, but this is probably a more appropriate place.

@honzajavorek

This comment has been minimized.

Copy link
Member

honzajavorek commented Mar 20, 2017

@TotempaaltJ Actually, I think a new issue linking this one would be nice! I agree it's a good idea to give a standard option to bypass the handler logic.

@TotempaaltJ

This comment has been minimized.

Copy link

TotempaaltJ commented Mar 20, 2017

Alright I created #755 ^

honzajavorek added a commit that referenced this issue Jan 3, 2019

@honzajavorek honzajavorek referenced this issue Jan 3, 2019

Merged

Improve Docker docs #1182

2 of 3 tasks complete

honzajavorek added a commit that referenced this issue Jan 3, 2019

honzajavorek added a commit that referenced this issue Jan 3, 2019

@ApiaryBot

This comment has been minimized.

Copy link
Collaborator

ApiaryBot commented Jan 8, 2019

🎉 This issue has been resolved in version 5.4.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ApiaryBot ApiaryBot added the released label Jan 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment