https://github.com/darmiel/yadwh
Yet Another Docker WebHook
https://github.com/darmiel/yadwh
cicd deployment docker webhook
Last synced: about 1 year ago
JSON representation
Yet Another Docker WebHook
- Host: GitHub
- URL: https://github.com/darmiel/yadwh
- Owner: darmiel
- Created: 2021-12-29T16:50:06.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-11T20:40:18.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T06:27:42.715Z (almost 2 years ago)
- Topics: cicd, deployment, docker, webhook
- Language: Go
- Homepage: https://github.com/darmiel/yadwh-action
- Size: 181 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
yadwh
Yet Another Docker Webhook
https://user-images.githubusercontent.com/71837281/148122013-aa3b92fd-d8b4-43eb-918a-b786a54f94b1.mov
---
This simple webhook service can be used to restart docker applications by calling a webhook URL,
inspired by [Watchtower](https://github.com/containrrr/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`:
````yaml
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`
```yaml
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_`:
```yaml
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_` to your credentials encoded as base64.
You can get the base64 encoded string by running this command:
```bash
$ echo -n '{"username": "", "password": ""}' | base64
```
---
## Full Example
```yaml
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.