dredd-hooks-ruby icon indicating copy to clipboard operation
dredd-hooks-ruby copied to clipboard

Add --host and --port flags for use in Docker.

Open petejohansonxo opened this issue 6 years ago • 11 comments

  • When running in a separate docker container from the main Dredd process, the hooks server will need to listen on 0.0.0.0 for instance, and optionally on a different port.

petejohansonxo avatar Mar 08 '19 18:03 petejohansonxo

LOL! i just saw this. will close mine 🤦‍♂️

rayzeller avatar Mar 14 '19 21:03 rayzeller

Hi, thanks for the PRs! I'll take a look at them, it just might take some time as I neglected this part of the Dredd world for a while and I need to do some reading to get the full context - I think this feature was mentioned in https://github.com/apiaryio/dredd-hooks-template/issues/11 and others.

Also, it might make sense to finally update the dependencies here. As far as I remember, we got stuck on something with the updates previously.

honzajavorek avatar Mar 15 '19 08:03 honzajavorek

Thanks! For more context, we're just getting up and running w/ Dredd + OpenAPI v3 spec, but I do have this working perfectly in CircleCI now using my fork + stock Dredd docker image, e..g:

services:
  dredd_hooks:
    build:
      context: ../../
      dockerfile: dockerfiles/Dockerfile.api
    command: ["bundle", "exec", "dredd-hooks-ruby", "--host", "0.0.0.0", "./api/dredd/*hooks.rb"]
    expose:
      - "61321"
    depends_on:
      - db
  dredd:
    image: apiaryio/dredd:stable
    depends_on:
      - api
      - dredd_hooks
    volumes:
      - ../:/data
    command: ["dredd", "--server-wait", "10" , "--language", "more", "--server", "more", "--hooks-worker-handler-host", "dredd_hooks", "/data/openapi.yaml", "http://api:4005"]

I've omitted the sections specific to running the api service in our case. I was able to avoid building a custom image by just leveraging the more command as my hooks binary, since it properly responds to TERM, and will happily idle waiting for more STDIN to view, and by mapping my spec file directory into the container w/ a volume.

petejohansonxo avatar Mar 15 '19 14:03 petejohansonxo

Just to let you know I didn't forget about this - it actually prompted me to revisit the hook template (see https://github.com/apiaryio/dredd-hooks-template/issues/23) and to get the Ruby hooks back into shape. That's something which is going to postpone merging this particular PR, but I think will be beneficial for everyone.

We surely want this to get merged eventually. Meanwhile, would you be so awesome to look into the changes made by @rayzeller in the https://github.com/apiaryio/dredd-hooks-ruby/pull/34 and pick up the good ideas he had, like updating the docs etc.? No rush, as the above will take me some time. Thanks!

honzajavorek avatar Mar 18 '19 15:03 honzajavorek

@honzajavorek Thanks for the work on this! I went ahead and pulled in the docs changes from @rayzeller (thanks for that!) and added to this branch.

Those changes do make some assumptions about a new release immediately after this PR is merged, so if that's not the plan, they should be adjusted accordingly.

petejohansonxo avatar Mar 19 '19 13:03 petejohansonxo

@petejohansonxo, curious can you provide any more info on your circleci/config.yml? i'm having trouble getting circle to recognize my hook server.

rayzeller avatar Mar 22 '19 23:03 rayzeller

@rayzeller I can give you the broad strokes, in essence it looks like this:

api_specs:
  machine:
    docker_layer_caching: true

  steps:
    - checkout
    - run: docker-compose build
    - run: docker-compose run --rm api 'some system/db setup script'
   - run: docker-compose up --abort-on-container-exit --exit-code-from dredd

And our docker-compose.yml file is like I posted before, with the addition of an api service that is from our custom docker image that wraps up our Sinatra based API and a db service that uses stock mysql docker image.

HTH.

petejohansonxo avatar Mar 26 '19 14:03 petejohansonxo

FYI, one of the newer versions of apiaryio/dredd (docker) is not handling dredd hooks at all. i now have my config locked at apiaryio/dredd:11.0.2

rayzeller avatar Jun 20 '19 00:06 rayzeller

@rayzeller Would you please file an issue here with some details on what doesn't work? We did quite some internal changes to Dredd lately and I'd like to avoid any regressions.

BTW I'm still working on getting the Ruby hooks into a good shape, starting with https://github.com/apiaryio/dredd-hooks-ruby/pull/37, but it takes some time. I'm looking forward to unblock all this and get the --host and --port working as well.

honzajavorek avatar Jun 20 '19 11:06 honzajavorek

@honzajavorek thanks for the response. i narrowed it down to https://github.com/apiaryio/dredd/releases/tag/v11.1.4. my configuration didn't require a hookfile to be set, but after setting it to hooks.rb, i finally get output, so I'm not going to file an issue at this point. i'm back at apiary/dredd:stable

rayzeller avatar Jun 20 '19 16:06 rayzeller

What's the status on getting this reviewed and merged in?

rayzeller avatar Mar 24 '21 22:03 rayzeller