mirror of
https://github.com/vimagick/dockerfiles.git
synced 2024-12-25 02:04:06 +02:00
update webhook
This commit is contained in:
parent
308237e3ad
commit
15cec50abe
@ -2,22 +2,20 @@
|
||||
# Dockerfile for webhook
|
||||
#
|
||||
|
||||
FROM golang:alpine AS build
|
||||
ENV CGO_ENABLED=0
|
||||
ENV GOOS=linux
|
||||
ENV GOARCH=amd64
|
||||
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
|
||||
MAINTAINER kev <noreply@easypi.pro>
|
||||
|
||||
RUN set -xe \
|
||||
&& apk add -U bash \
|
||||
coreutils \
|
||||
curl \
|
||||
jq \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
COPY ./webhook /usr/local/bin/
|
||||
|
||||
WORKDIR /scripts
|
||||
VOLUME /scripts
|
||||
|
||||
RUN apk add --no-cache bash coreutils curl jq
|
||||
COPY --from=build /go/bin/webhook /usr/local/bin/
|
||||
VOLUME /etc/webhook
|
||||
EXPOSE 9000
|
||||
|
||||
ENTRYPOINT ["webhook"]
|
||||
CMD ["-help"]
|
||||
CMD ["-header", "Access-Control-Allow-Origin=*", "-hooks", "/etc/webhook/hooks.json", "-verbose"]
|
||||
|
@ -1,14 +0,0 @@
|
||||
.PHONY: webhook
|
||||
|
||||
export CGO_ENABLED=0
|
||||
export GOPATH = /tmp/go
|
||||
export GOOS = linux
|
||||
export GOARCH = amd64
|
||||
|
||||
webhook:
|
||||
go get -d github.com/adnanh/webhook
|
||||
go build --ldflags '-s -extldflags "-static"' -i -o webhook github.com/adnanh/webhook
|
||||
|
||||
clean:
|
||||
rm -rf $(GOPATH)
|
||||
rm -f webhook
|
@ -7,64 +7,53 @@ webhook
|
||||
to easily create HTTP endpoints (hooks) on your server, which you can use to
|
||||
execute configured commands.
|
||||
|
||||
## Build Binary
|
||||
|
||||
To build a docker image from scratch, we need to build static linked binary.
|
||||
|
||||
```bash
|
||||
$ go get -d github.com/adnanh/webhook
|
||||
$ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -installsuffix cgo -ldflags '-s -extld ld -extldflags -static' -a -x -o webhook github.com/adnanh/webhook
|
||||
$ file webhook
|
||||
```
|
||||
|
||||
## Directory Tree
|
||||
|
||||
```
|
||||
~/fig/webhook/
|
||||
├── docker-compose.yml
|
||||
└── scripts/
|
||||
└── data/
|
||||
├── hooks.json
|
||||
└── test.sh* (executable)
|
||||
```
|
||||
|
||||
docker-compose.yml
|
||||
|
||||
```
|
||||
```yaml
|
||||
webhook:
|
||||
image: vimagick/webhook
|
||||
command: -hooks hooks.json -verbose
|
||||
ports:
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- "./scripts:/scripts"
|
||||
- "./data:/etc/webhook"
|
||||
restart: always
|
||||
```
|
||||
|
||||
hooks.json
|
||||
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "test",
|
||||
"execute-command": "/scripts/test.sh",
|
||||
"command-working-directory": "/scripts"
|
||||
"execute-command": "/etc/webhook/test.sh",
|
||||
"command-working-directory": "/etc/webhook"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
test.sh
|
||||
|
||||
```
|
||||
```bash
|
||||
#!/bin/bash
|
||||
echo 'hello world'
|
||||
```
|
||||
|
||||
## Up and Running
|
||||
|
||||
```
|
||||
```bash
|
||||
$ cd ~/fig/webhook/
|
||||
|
||||
$ chmod +x scripts/test.sh
|
||||
$ chmod +x data/test.sh
|
||||
|
||||
$ docker-compose up -d
|
||||
Creating webhook_webhook_1...
|
||||
|
7
webhook/data/hooks.json
Normal file
7
webhook/data/hooks.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": "test",
|
||||
"execute-command": "/etc/webhook/test.sh",
|
||||
"command-working-directory": "/etc/webhook"
|
||||
}
|
||||
]
|
1
webhook/scripts/test.sh → webhook/data/test.sh
Normal file → Executable file
1
webhook/scripts/test.sh → webhook/data/test.sh
Normal file → Executable file
@ -1,3 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo 'hello world'
|
||||
|
@ -1,8 +1,7 @@
|
||||
webhook:
|
||||
image: vimagick/webhook
|
||||
command: -hooks hooks.json -verbose
|
||||
ports:
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- "./scripts:/scripts"
|
||||
- "./data:/etc/webhook"
|
||||
restart: always
|
||||
|
@ -1,7 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": "test",
|
||||
"execute-command": "/scripts/test.sh",
|
||||
"command-working-directory": "/scripts"
|
||||
}
|
||||
]
|
BIN
webhook/webhook
BIN
webhook/webhook
Binary file not shown.
Loading…
Reference in New Issue
Block a user