Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

petejohansonxo
Copy link

  • 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.

* 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.
@rayzeller
Copy link

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

@honzajavorek
Copy link
Contributor

honzajavorek commented Mar 15, 2019

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 apiaryio/dredd-hooks-template#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.

@petejohansonxo
Copy link
Author

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.

@honzajavorek
Copy link
Contributor

honzajavorek commented Mar 18, 2019

Just to let you know I didn't forget about this - it actually prompted me to revisit the hook template (see apiaryio/dredd-hooks-template#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 #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!

@petejohansonxo
Copy link
Author

@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.

@rayzeller
Copy link

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

@petejohansonxo
Copy link
Author

@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.

@rayzeller
Copy link

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

@honzajavorek
Copy link
Contributor

@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 #37, but it takes some time. I'm looking forward to unblock all this and get the --host and --port working as well.

@rayzeller
Copy link

@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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants