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.
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"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"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: mysecretDone!
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.
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>"}' | base64version: "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: mysecretGET X.X.X.X:8080/BACKEND_PROD/mysecret would now restart the backend-service.
