Simple WebHook - Restart a Container using Webhooks
|
All checks were successful
ci/woodpecker/push/build Pipeline was successful
how did that even ever work? |
||
|---|---|---|
| .woodpecker | ||
| src | ||
| .dockerignore | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| Dockerfile | ||
| LICENSE | ||
| README.md | ||
swh - Simple Webhook
I needed a Service to restart a Docker Container when I push changes to a git repository. This tool does exactly that.
Usage:
Configure a Git Webhook to your needs. Enter a Secret in the Webhook GUI of your Git Forge and note it down.
The webhook URL is http[s]://ip_or_url[:port]/.
You can either start the docker image using this command:
docker run -it -d -v /var/run/docker.sock:/var/run/docker.sock -e SWH_SECRET="YOUR_SECRET" -e SWH_CONTAINER_NAME="YOUR_CONTAINER_NAME" git.schmarrn.dev/andi/swh:latest
The service listens to port 3000.
I recommend using a reverse proxy.
A docker compose file would look like this:
version: "3.8"
services:
swh:
image: git.schmarrn.dev/andi/swh:latest
environment:
SWH_SECRET: "YOUR_SECRET"
SWH_CONTAINER_NAME: "YOUR_CONTAINER_NAME"
volumes:
- /var/run/docker.sock:/var/run/docker.sock