1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-25 02:04:06 +02:00

update webhook

This commit is contained in:
kev 2019-01-09 18:59:22 +08:00
parent 308237e3ad
commit 15cec50abe
8 changed files with 30 additions and 59 deletions

View File

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

View File

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

View File

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

@ -1,3 +1,2 @@
#!/bin/bash
echo 'hello world'

View File

@ -1,8 +1,7 @@
webhook:
image: vimagick/webhook
command: -hooks hooks.json -verbose
ports:
- "9000:9000"
volumes:
- "./scripts:/scripts"
- "./data:/etc/webhook"
restart: always

View File

@ -1,7 +0,0 @@
[
{
"id": "test",
"execute-command": "/scripts/test.sh",
"command-working-directory": "/scripts"
}
]

Binary file not shown.