Published on

Quick Tip On Setting Up The Hookdeck-CLI With Docker

Authors

Hookdeck is a fantastic tool that helps you manage and tunnel external webhooks into a local development server, among other things.

The Hookdeck-CLI is simple and works pretty well; however, I wanted its integration into our workflow to be more portable for fellow developers on our project. I was trying to avoid having everyone install yet-another-cli-tool.

Using Docker Compose

Our project already uses docker-compose to wire up the various services in our app, so why not leverage what we already have?

Take advantage of docker-compose.override.yml for local development.

Overriding the entrypoint command defined in the hookdeck/hookdeck-cli container, we can:

  • Check if a stored auth config file exists in our volume or prompt user to login;
  • Listen and tunnel to our target docker service.
#docker-compose.override.yml

version: "3.7"
services:

  # ...

  hookdeck:
    image: "hookdeck/hookdeck-cli:v0.4.4"
    entrypoint: ["/bin/sh","-c"]
    command:
    - |
       /bin/hookdeck version
       [ -f /root/.config/hookdeck/config.toml ] && echo "Hookdeck config found!" || /bin/hookdeck login
       /bin/hookdeck listen http://target-docker-service-name:8080 your-hookdeck-source-name

    volumes:
      - hookdeck:/root/.config/hookdeck  # Store auth tokens in volume

    networks:
      - your-app-network # This is important! This service needs to be on the same network as your app or they wont be able to communicate


volumes:
  hookdeck:


networks:
  your-app-network:
    driver: bridge

Now, if you run docker-compose up hookdeck. The hookdeck-cli container will start and output a link to login from the terminal. Once you login, the creds are stored in a persistent volume and are always available on docker-compose up.

And that's it! Simple and portable. :)

Hope this helps! Hit me up on Twitter: @Mineo27 if you have any issues/questions.

© 2015-2022 AnthonyMineo.com