Skip to content
darmielPublic

About

Yet Another Docker WebHook

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gopher

yadwh

Yet Another Docker Webhook

Screen.Recording.2022-01-04.at.21.39.38.mov

This simple webhook service can be used to restart docker applications by calling a webhook URL,
inspired by Watchtower.

Step 1

Add a label with the key io.d2a.yadwh.ug to your containers you wish to restart, with a group-name, like BACKEND_PROD:

services:
  backend:
    labels:
      - "io.d2a.yadwh.ug=BACKEND_PROD"

Step 2

Add an instance of yadwh to your docker-compose.yml, mount your Docker socket and expose the port 80

services:
  backend:
    # ...
  yadwh:
    image: darmiel/yadwh:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "8080:80"

Step 3

Choose a secret for your webhook my setting the environment variable WH_SECRET_<NAME>:

services:
  backend:
  # ...
  yadwh:
    image: darmiel/yadwh:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "8080:80"
    environment:
      WH_SECRET_BACKEND_PROD: mysecret

Done!

Once the webhook is called, all containers with the label io.d2a.yadwh.ug set to BACKEND_PROD will be stopped, updated and started again.

Auth

If your container is private or behind a docker registry auth, set the environment variable WH_AUTH_<NAME> to your credentials encoded as base64.

You can get the base64 encoded string by running this command:

$ echo -n '{"username": "<username>", "password": "<password>"}' | base64

Full Example

version: "3"

services:
  backend:
    image: ghcr.io/qwiri/gyf-backend:prod
    # ...
    labels:
      - "io.d2a.yadwh.ug=BACKEND_PROD"

  yadwh:
    image: darmiel/yadwh
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    restart: on-failure
    ports:
      - "8080:80"
    environment:
      WH_SECRET_BACKEND_PROD: mysecret

GET X.X.X.X:8080/BACKEND_PROD/mysecret would now restart the backend-service.

About

Yet Another Docker WebHook

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages

⌂ 换网址