Compare commits

...

6 Commits

Author SHA1 Message Date
Lucien 4607559329
Merge fe16052056 into f45929a477 2024-02-21 08:51:53 +05:30
kevin f45929a477 update webhook 2024-02-20 21:01:16 +08:00
kev a8a528b6b4 update webhook 2024-02-20 18:27:53 +08:00
Lucien fe16052056
Merge pull request #1 from LucienShui/imgbot
[ImgBot] Optimize images
2020-08-26 11:07:25 +08:00
Lucien f21ffd6bfa
Avoid inactive connection
https://github.com/tinyproxy/tinyproxy/issues/199
2020-08-26 11:02:06 +08:00
ImgBotApp 1c434b2d2e
[ImgBot] Optimize images
*Total -- 181.18kb -> 152.26kb (15.96%)

/krakend/data/krakend.png -- 32.27kb -> 23.93kb (25.84%)
/node-red/screenshot.png -- 80.86kb -> 61.85kb (23.51%)
/rtmp/server/html/img/cctv.jpg -- 60.20kb -> 58.80kb (2.33%)
/tesseract/data/chinese.jpg -- 7.84kb -> 7.67kb (2.19%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
2020-08-26 02:52:07 +00:00
11 changed files with 84 additions and 63 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -10,6 +10,7 @@ RUN set -xe \
&& sed -i -e '/^Allow /s/^/#/' \
-e '/^ConnectPort /s/^/#/' \
-e '/^#DisableViaHeader /s/^#//' \
-e 's/^Timeout.*/Timeout 10/' \
/etc/tinyproxy/tinyproxy.conf
VOLUME /etc/tinyproxy

View File

@ -2,23 +2,42 @@
# 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 \
bind-tools \
ca-certificates \
coreutils \
curl \
curlie \
gawk \
gcompat \
grep \
iputils-ping \
jq \
mosquitto-clients \
openssh \
sed \
tar \
wget \
xsv \
&& 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
CMD ["-hooks", "hooks.json", "-hooks", "hooks.yaml", "-hotreload", "-template", "-verbose"]
# See: https://github.com/adnanh/webhook/blob/master/docs/Webhook-Parameters.md
CMD ["-hooks=hooks.json", "-hooks=hooks.yaml", "-hotreload", "-port=9000", "-template", "-urlprefix=hooks"]

View File

@ -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

View File

@ -1 +0,0 @@
[]

13
webhook/data/hooks.yaml Normal file
View 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"

View File

@ -1,5 +1,3 @@
#!/bin/bash
echo 'hello world'
cat $HOOK_PAYLOAD

View File

@ -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