From 8f133b9df4cd994fe4b35739e566bd75226dc71f Mon Sep 17 00:00:00 2001 From: ReachableCEO Date: Wed, 4 Feb 2026 08:29:01 -0500 Subject: [PATCH] feat: add webhook Cloudron package (API-Gateway) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create Dockerfile for webhook (Go application) - Add CloudronManifest.json with basic configuration - Include README.md with usage documentation - Add hooks.json.example configuration template - Add logo.png (256x256) - Add CHANGELOG.md for version tracking Webhook is a lightweight configurable tool written in Go that allows creating HTTP endpoints (hooks) on your server for executing configured commands. Package includes: - Multi-stage Dockerfile using golang:1.21-alpine - Cloudron base image for runtime - Configuration on port 9000 - Localstorage addon for hooks.json - 256MB memory limit 💘 Generated with Crush Assisted-by: GLM-4.7 via Crush --- .../API-Gateway/webhook/CHANGELOG.md | 9 +++ .../API-Gateway/webhook/CloudronManifest.json | 30 +++++++ .../API-Gateway/webhook/Dockerfile | 40 ++++++++++ .../API-Gateway/webhook/README.md | 75 ++++++++++++++++++ .../API-Gateway/webhook/hooks.json.example | 60 ++++++++++++++ .../API-Gateway/webhook/logo.png | Bin 0 -> 2532 bytes 6 files changed, 214 insertions(+) create mode 100644 Package-Workspace/API-Gateway/webhook/CHANGELOG.md create mode 100644 Package-Workspace/API-Gateway/webhook/CloudronManifest.json create mode 100644 Package-Workspace/API-Gateway/webhook/Dockerfile create mode 100644 Package-Workspace/API-Gateway/webhook/README.md create mode 100644 Package-Workspace/API-Gateway/webhook/hooks.json.example create mode 100644 Package-Workspace/API-Gateway/webhook/logo.png diff --git a/Package-Workspace/API-Gateway/webhook/CHANGELOG.md b/Package-Workspace/API-Gateway/webhook/CHANGELOG.md new file mode 100644 index 0000000..76cb8b3 --- /dev/null +++ b/Package-Workspace/API-Gateway/webhook/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +## [2.8.1] - 2025-01-24 + +### Added +- Initial Cloudron package for webhook +- Multi-stage Dockerfile for optimized image size +- Example hooks.json configuration file +- Documentation and usage instructions diff --git a/Package-Workspace/API-Gateway/webhook/CloudronManifest.json b/Package-Workspace/API-Gateway/webhook/CloudronManifest.json new file mode 100644 index 0000000..0ef5bf2 --- /dev/null +++ b/Package-Workspace/API-Gateway/webhook/CloudronManifest.json @@ -0,0 +1,30 @@ +{ + "version": 1, + "manifestVersion": 2, + "type": "app", + "id": "io.cloudron.webhook", + "title": "Webhook", + "description": "A lightweight configurable tool written in Go that allows you to easily create HTTP endpoints (hooks) on your server", + "author": "adnanh", + "website": "https://github.com/adnanh/webhook", + "contactEmail": "cloudron@tsys.dev", + "tagline": "Lightweight webhook receiver for automation", + "version": "2.8.1", + "healthCheckPath": "/", + "httpPort": 9000, + "memoryLimit": 256, + "addons": { + "localstorage": true + }, + "tcpPorts": { + "HTTP_PORT": { + "description": "Webhook HTTP port", + "defaultValue": 9000 + } + }, + "mediaLinks": [ + "https://github.com/adnanh/webhook/raw/development/docs/logo/logo-256x256.png" + ], + "changelog": "Initial Cloudron package for webhook", + "icon": "file://logo.png" +} \ No newline at end of file diff --git a/Package-Workspace/API-Gateway/webhook/Dockerfile b/Package-Workspace/API-Gateway/webhook/Dockerfile new file mode 100644 index 0000000..73a82bf --- /dev/null +++ b/Package-Workspace/API-Gateway/webhook/Dockerfile @@ -0,0 +1,40 @@ +FROM golang:1.21-alpine AS builder + +# Install build dependencies +RUN apk add --no-cache git make + +# Set working directory +WORKDIR /app + +# Copy go mod files +COPY repo/go.mod repo/go.sum ./ + +# Download dependencies +RUN go mod download + +# Copy source code +COPY repo/ . + +# Build application +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o webhook + +# Final stage +FROM cloudron/base:3.2.0 + +# Copy binary from builder +COPY --from=builder /app/webhook /usr/local/bin/webhook + +# Create data directory +RUN mkdir -p /app/data + +# Set permissions +RUN chmod +x /usr/local/bin/webhook + +# Set working directory +WORKDIR /app + +# Expose port +EXPOSE 9000 + +# Start application +CMD ["/usr/local/bin/webhook", "-hooks", "/app/data/hooks.json", "-verbose"] diff --git a/Package-Workspace/API-Gateway/webhook/README.md b/Package-Workspace/API-Gateway/webhook/README.md new file mode 100644 index 0000000..6cddd17 --- /dev/null +++ b/Package-Workspace/API-Gateway/webhook/README.md @@ -0,0 +1,75 @@ +# Webhook Cloudron Package + +## Description + +Webhook 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. + +## Features + +- Define HTTP endpoints that execute commands on your server +- Pass data from HTTP requests to your commands +- Specify rules that must be satisfied for hooks to trigger +- Supports JSON and YAML configuration files +- Trigger rules for security (secrets, headers, etc.) +- Hot-reload configuration without restart +- Support for multipart form data +- Template support for request values + +## Configuration + +The webhook application reads configuration from `/app/data/hooks.json` (or `/app/data/hooks.yaml`). + +### Example Configuration + +```json +[ + { + "id": "redeploy-webhook", + "execute-command": "/var/scripts/redeploy.sh", + "command-working-directory": "/var/webhook", + "trigger-rule": { + "and": [ + { + "match": { + "type": "payload-hmac-sha1", + "secret": "mysecret", + "parameter": { + "source": "header", + "name": "X-Hub-Signature" + } + } + } + ] + } + } +] +``` + +See [webhook documentation](https://github.com/adnanh/webhook/tree/master/docs) for detailed configuration options. + +## Usage + +1. Install the webhook app on Cloudron +2. Navigate to the File Manager +3. Create or edit `hooks.json` in the `/app/data` directory +4. Restart the app to apply configuration changes +5. Access your webhook endpoints at `http://your-app.cloudron.app/hooks/{hook-id}` + +## Documentation + +For more information on configuring webhooks, visit: +- [Hook Definition](https://github.com/adnanh/webhook/blob/master/docs/Hook-Definition.md) +- [Hook Examples](https://github.com/adnanh/webhook/blob/master/docs/Hook-Examples.md) +- [Hook Rules](https://github.com/adnanh/webhook/blob/master/docs/Hook-Rules.md) +- [Webhook Parameters](https://github.com/adnanh/webhook/blob/master/docs/Webhook-Parameters.md) + +## Security Considerations + +- Always use trigger rules to secure your hooks +- Never expose sensitive commands without proper authentication +- Use HMAC signatures for verifying webhook sources +- Consider IP-based rules for additional security + +## Upstream + +[GitHub Repository](https://github.com/adnanh/webhook) diff --git a/Package-Workspace/API-Gateway/webhook/hooks.json.example b/Package-Workspace/API-Gateway/webhook/hooks.json.example new file mode 100644 index 0000000..90cd275 --- /dev/null +++ b/Package-Workspace/API-Gateway/webhook/hooks.json.example @@ -0,0 +1,60 @@ +[ + { + "id": "webhook", + "execute-command": "/home/adnan/redeploy-go-webhook.sh", + "command-working-directory": "/home/adnan/go", + "response-message": "I got the payload!", + "response-headers": + [ + { + "name": "Access-Control-Allow-Origin", + "value": "*" + } + ], + "pass-arguments-to-command": + [ + { + "source": "payload", + "name": "head_commit.id" + }, + { + "source": "payload", + "name": "pusher.name" + }, + { + "source": "payload", + "name": "pusher.email" + } + ], + "trigger-rule": + { + "and": + [ + { + "match": + { + "type": "payload-hmac-sha1", + "secret": "mysecret", + "parameter": + { + "source": "header", + "name": "X-Hub-Signature" + } + } + }, + { + "match": + { + "type": "value", + "value": "refs/heads/master", + "parameter": + { + "source": "payload", + "name": "ref" + } + } + } + ] + } + } +] diff --git a/Package-Workspace/API-Gateway/webhook/logo.png b/Package-Workspace/API-Gateway/webhook/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..ae3a685d10316d66ebc79bd0970271aa267e772c GIT binary patch literal 2532 zcmeHJZAep57=F+3PVY2JjdHb2Ws#wT{s>*!njiBEY*>hiidzgMQgBAeFr8PCG`MaW zQ4ppH1(IJALJf2-3fBi=WvCG`ZA#^;%`cpD-rF7Yt6xDyLH;`DIp;YK@B6&xaNf&V z@-%@HFf9+yew(Xvd%6>{R- z$V~8)D8LAXOz{k#g8f*bC7tte%k$6H!*7LR*Dlj+snl!Av8GB;fSr*huVI1zbUno! zH}xfb5+mBlof`GMV{E!4^@a>{%QH&O}y<4VaoA}1#+~6A?Q%` z4M2|;CRvGQ$Y@nzBETmB%D}9Tpay{hYPSYA`2FWgR$d1$JJ{i3N_$!J+u#m+^#&@i zjC{3J978nGE2TWef5JUHSDqCQb?AhG-W0owE1yI9%u;)MDq!Z*6Y~ugP ZkLlp7EF{^A#?@T+1{o=GSx=I(_8a2PEdc-k literal 0 HcmV?d00001