mirror of
https://github.com/vimagick/dockerfiles.git
synced 2025-01-08 04:04:42 +02:00
update webhook
This commit is contained in:
parent
3bdbe90434
commit
a8a528b6b4
@ -2,23 +2,25 @@
|
||||
# Dockerfile for webhook
|
||||
#
|
||||
|
||||
FROM golang:alpine AS build
|
||||
ENV CGO_ENABLED=0
|
||||
ENV GOOS=linux
|
||||
ENV GOARCH=amd64
|
||||
ENV GO111MODULE=off
|
||||
WORKDIR /go/bin
|
||||
RUN apk add --no-cache git
|
||||
RUN go get -d -v github.com/adnanh/webhook
|
||||
RUN go build --ldflags '-s -extldflags "-static"' -i -o webhook github.com/adnanh/webhook
|
||||
|
||||
FROM alpine:3
|
||||
MAINTAINER EasyPi Software Foundation
|
||||
RUN apk add --no-cache bash coreutils curl jq
|
||||
COPY --from=build /go/bin/webhook /usr/local/bin/
|
||||
|
||||
ARG WEBHOOK_VERSION=2.8.1
|
||||
ARG WEBHOOK_OS=linux
|
||||
ARG WEBHOOK_ARCH=amd64
|
||||
ARG WEBHOOK_FILE=webhook-$WEBHOOK_OS-$WEBHOOK_ARCH.tar.gz
|
||||
ARG WEBHOOK_URL=https://github.com/adnanh/webhook/releases/download/$WEBHOOK_VERSION/$WEBHOOK_FILE
|
||||
|
||||
RUN set -xe \
|
||||
&& apk add --no-cache bash coreutils curl gcompat jq \
|
||||
&& curl -sSL $WEBHOOK_URL | tar xz -C /usr/local/bin ${WEBHOOK_FILE%.tar.gz}/webhook --strip 1 \
|
||||
&& webhook --version
|
||||
|
||||
WORKDIR /etc/webhook
|
||||
VOLUME /etc/webhook
|
||||
|
||||
EXPOSE 9000
|
||||
|
||||
ENTRYPOINT ["webhook"]
|
||||
# Doc: https://github.com/adnanh/webhook/blob/master/docs/Webhook-Parameters.md
|
||||
# See: https://github.com/adnanh/webhook/blob/master/docs/Webhook-Parameters.md
|
||||
CMD ["-hooks", "hooks.json", "-hooks", "hooks.yaml", "-hotreload", "-template", "-verbose"]
|
||||
|
@ -9,7 +9,7 @@ execute configured commands.
|
||||
|
||||
## Directory Tree
|
||||
|
||||
```
|
||||
```bash
|
||||
~/fig/webhook/
|
||||
├── docker-compose.yml
|
||||
└── data/
|
||||
@ -17,36 +17,24 @@ execute configured commands.
|
||||
└── test.sh* (executable)
|
||||
```
|
||||
|
||||
docker-compose.yml
|
||||
File: data/hooks.yaml
|
||||
|
||||
```yaml
|
||||
webhook:
|
||||
image: vimagick/webhook
|
||||
ports:
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- "./data:/etc/webhook"
|
||||
restart: always
|
||||
- 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
|
||||
```
|
||||
|
||||
hooks.json
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "test",
|
||||
"execute-command": "/etc/webhook/test.sh",
|
||||
"command-working-directory": "/etc/webhook",
|
||||
"include-command-output-in-response": true
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
test.sh
|
||||
File: data/test.sh
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
echo 'hello world'
|
||||
cat $HOOK_PAYLOAD
|
||||
```
|
||||
|
||||
## Up and Running
|
||||
@ -59,26 +47,27 @@ $ chmod +x data/test.sh
|
||||
$ docker-compose up -d
|
||||
Creating webhook_webhook_1...
|
||||
|
||||
$ curl http://localhost:9000/hooks/test
|
||||
$ curl http://localhost:9000/hooks/test -d hello=world
|
||||
hello world
|
||||
{"hello":"world"}
|
||||
|
||||
$ docker-compose logs
|
||||
Attaching to webhook_webhook_1
|
||||
webhook_1 | [webhook] 2015/11/05 04:26:52 version 2.3.5 starting
|
||||
webhook_1 | [webhook] 2015/11/05 04:26:52 setting up os signal watcher
|
||||
webhook_1 | [webhook] 2015/11/05 04:26:52 attempting to load hooks from hooks.json
|
||||
webhook_1 | [webhook] 2015/11/05 04:26:52 loaded 1 hook(s) from file
|
||||
webhook_1 | [webhook] 2015/11/05 04:26:52 > test
|
||||
webhook_1 | [webhook] 2015/11/05 04:26:52 starting insecure (http) webhook on :9000
|
||||
webhook_1 | [webhook] 2015/11/05 04:26:52 os signal watcher ready
|
||||
webhook_1 | [webhook] 2015/11/05 04:27:11 Started GET /hooks/test
|
||||
webhook_1 | [webhook] 2015/11/05 04:27:11 Completed 200 OK in 390.207µs
|
||||
webhook_1 | [webhook] 2015/11/05 04:27:11 test got matched (1 time(s))
|
||||
webhook_1 | [webhook] 2015/11/05 04:27:11 test hook triggered successfully
|
||||
webhook_1 | [webhook] 2015/11/05 04:27:11 executing /scripts/test.sh (/scripts/test.sh) with arguments [/scripts/test.sh] using /scripts as cwd
|
||||
webhook_1 | [webhook] 2015/11/05 04:27:11 command output: hello world
|
||||
webhook_1 |
|
||||
webhook_1 | [webhook] 2015/11/05 04:27:11 finished handling test
|
||||
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
|
||||
```
|
||||
|
||||
[1]: https://github.com/adnanh/webhook
|
||||
|
@ -1 +0,0 @@
|
||||
[]
|
13
webhook/data/hooks.yaml
Normal file
13
webhook/data/hooks.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
- 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
|
||||
|
||||
- id: osmand
|
||||
execute-command: '/bin/echo'
|
||||
pass-arguments-to-command:
|
||||
- source: entire-query
|
||||
response-message: "OK\n"
|
@ -1,5 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo 'hello world'
|
||||
|
||||
cat $HOOK_PAYLOAD
|
||||
|
@ -1,7 +1,9 @@
|
||||
webhook:
|
||||
image: vimagick/webhook
|
||||
ports:
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- "./data:/etc/webhook"
|
||||
restart: always
|
||||
version: "3.8"
|
||||
services:
|
||||
webhook:
|
||||
image: vimagick/webhook
|
||||
ports:
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- "./data:/etc/webhook"
|
||||
restart: unless-stopped
|
||||
|
Loading…
Reference in New Issue
Block a user