1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-16 11:58:47 +00:00
dockerfiles/webhook/README.md

74 lines
2.2 KiB
Markdown
Raw Normal View History

2015-11-05 03:32:10 +00:00
webhook
=======
2015-11-05 04:31:44 +00:00
![](https://badge.imagelayers.io/vimagick/webhook:latest.svg)
2015-11-05 03:32:10 +00:00
[webhook][1] is a lightweight configurable tool written in Go, that allows you
to easily create HTTP endpoints (hooks) on your server, which you can use to
execute configured commands.
2015-11-05 04:20:42 +00:00
## Directory Tree
2024-02-20 10:27:53 +00:00
```bash
2015-11-05 04:20:42 +00:00
~/fig/webhook/
├── docker-compose.yml
2019-01-09 10:59:22 +00:00
└── data/
2015-11-05 04:20:42 +00:00
├── hooks.json
2015-11-05 04:31:44 +00:00
└── test.sh* (executable)
2015-11-05 04:20:42 +00:00
```
2024-02-20 10:27:53 +00:00
File: data/hooks.yaml
2015-11-05 04:20:42 +00:00
2019-01-09 10:59:22 +00:00
```yaml
2024-02-20 10:27:53 +00:00
- id: test
execute-command: /etc/webhook/test.sh
pass-file-to-command:
- source: entire-payload
envname: HOOK_PAYLOAD
command-working-directory: /etc/webhook
include-command-output-in-response: true
2015-11-05 04:20:42 +00:00
```
2024-02-20 10:27:53 +00:00
File: data/test.sh
2015-11-05 04:20:42 +00:00
2019-01-09 10:59:22 +00:00
```bash
2015-11-05 04:20:42 +00:00
#!/bin/bash
echo 'hello world'
2024-02-20 10:27:53 +00:00
cat $HOOK_PAYLOAD
2015-11-05 04:20:42 +00:00
```
## Up and Running
2019-01-09 10:59:22 +00:00
```bash
2015-11-05 04:31:44 +00:00
$ cd ~/fig/webhook/
2019-01-09 10:59:22 +00:00
$ chmod +x data/test.sh
2016-01-25 10:16:08 +00:00
2015-11-05 04:20:42 +00:00
$ docker-compose up -d
2015-11-05 04:31:44 +00:00
Creating webhook_webhook_1...
2024-02-20 10:27:53 +00:00
$ curl http://localhost:9000/hooks/test -d hello=world
2019-01-09 11:09:32 +00:00
hello world
2024-02-20 10:27:53 +00:00
{"hello":"world"}
2015-11-05 04:31:44 +00:00
2015-11-05 04:20:42 +00:00
$ docker-compose logs
2015-11-05 04:31:44 +00:00
Attaching to webhook_webhook_1
2024-02-20 10:27:53 +00:00
webhook_1 | [webhook] 2024/02/20 04:26:52 version 2.8.1 starting
webhook_1 | [webhook] 2024/02/20 04:26:52 setting up os signal watcher
webhook_1 | [webhook] 2024/02/20 04:26:52 attempting to load hooks from hooks.json
webhook_1 | [webhook] 2024/02/20 04:26:52 loaded 1 hook(s) from file
webhook_1 | [webhook] 2024/02/20 04:26:52 > test
webhook_1 | [webhook] 2024/02/20 04:26:52 starting insecure (http) webhook on :9000
webhook_1 | [webhook] 2024/02/20 04:26:52 os signal watcher ready
webhook_1 | [webhook] 2024/02/20 04:27:11 Started GET /hooks/test
webhook_1 | [webhook] 2024/02/20 04:27:11 Completed 200 OK in 390.207µs
webhook_1 | [webhook] 2024/02/20 04:27:11 test got matched (1 time(s))
webhook_1 | [webhook] 2024/02/20 04:27:11 test hook triggered successfully
webhook_1 | [webhook] 2024/02/20 04:27:11 executing /scripts/test.sh (/scripts/test.sh) with arguments ["/etc/webhook/test.sh"] and environment [HOOK_PAYLOAD=/etc/webhook/HOOK_PAYLOAD967569167] using /etc/webhook as cwd
webhook_1 | [webhook] 2024/02/20 04:27:11 command output: hello world
webhook_1 | {"hello":"world"}
webhook_1 | [webhook] 2024/02/20 04:27:11 finished handling test
2015-11-05 04:20:42 +00:00
```
2015-11-05 03:32:10 +00:00
[1]: https://github.com/adnanh/webhook