mirror of
https://github.com/vimagick/dockerfiles.git
synced 2025-05-27 22:47:38 +02:00
update webhook
This commit is contained in:
parent
308237e3ad
commit
15cec50abe
@ -2,22 +2,20 @@
|
|||||||
# Dockerfile for webhook
|
# 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
|
FROM alpine
|
||||||
MAINTAINER kev <noreply@easypi.pro>
|
MAINTAINER kev <noreply@easypi.pro>
|
||||||
|
RUN apk add --no-cache bash coreutils curl jq
|
||||||
RUN set -xe \
|
COPY --from=build /go/bin/webhook /usr/local/bin/
|
||||||
&& apk add -U bash \
|
VOLUME /etc/webhook
|
||||||
coreutils \
|
|
||||||
curl \
|
|
||||||
jq \
|
|
||||||
&& rm -rf /var/cache/apk/*
|
|
||||||
|
|
||||||
COPY ./webhook /usr/local/bin/
|
|
||||||
|
|
||||||
WORKDIR /scripts
|
|
||||||
VOLUME /scripts
|
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
ENTRYPOINT ["webhook"]
|
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
|
to easily create HTTP endpoints (hooks) on your server, which you can use to
|
||||||
execute configured commands.
|
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
|
## Directory Tree
|
||||||
|
|
||||||
```
|
```
|
||||||
~/fig/webhook/
|
~/fig/webhook/
|
||||||
├── docker-compose.yml
|
├── docker-compose.yml
|
||||||
└── scripts/
|
└── data/
|
||||||
├── hooks.json
|
├── hooks.json
|
||||||
└── test.sh* (executable)
|
└── test.sh* (executable)
|
||||||
```
|
```
|
||||||
|
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
webhook:
|
webhook:
|
||||||
image: vimagick/webhook
|
image: vimagick/webhook
|
||||||
command: -hooks hooks.json -verbose
|
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000"
|
- "9000:9000"
|
||||||
volumes:
|
volumes:
|
||||||
- "./scripts:/scripts"
|
- "./data:/etc/webhook"
|
||||||
restart: always
|
restart: always
|
||||||
```
|
```
|
||||||
|
|
||||||
hooks.json
|
hooks.json
|
||||||
|
|
||||||
```
|
```json
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id": "test",
|
"id": "test",
|
||||||
"execute-command": "/scripts/test.sh",
|
"execute-command": "/etc/webhook/test.sh",
|
||||||
"command-working-directory": "/scripts"
|
"command-working-directory": "/etc/webhook"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
test.sh
|
test.sh
|
||||||
|
|
||||||
```
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo 'hello world'
|
echo 'hello world'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Up and Running
|
## Up and Running
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ cd ~/fig/webhook/
|
$ cd ~/fig/webhook/
|
||||||
|
|
||||||
$ chmod +x scripts/test.sh
|
$ chmod +x data/test.sh
|
||||||
|
|
||||||
$ docker-compose up -d
|
$ docker-compose up -d
|
||||||
Creating webhook_webhook_1...
|
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
|
#!/bin/bash
|
||||||
echo 'hello world'
|
echo 'hello world'
|
||||||
|
|
@ -1,8 +1,7 @@
|
|||||||
webhook:
|
webhook:
|
||||||
image: vimagick/webhook
|
image: vimagick/webhook
|
||||||
command: -hooks hooks.json -verbose
|
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000"
|
- "9000:9000"
|
||||||
volumes:
|
volumes:
|
||||||
- "./scripts:/scripts"
|
- "./data:/etc/webhook"
|
||||||
restart: always
|
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…
x
Reference in New Issue
Block a user