Skip to content

Commit

Permalink
添加Dockerfile&容器化支持
Browse files Browse the repository at this point in the history
  • Loading branch information
Viking602 committed Nov 24, 2022
1 parent abe318f commit c67bba0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM golang:1.19-alpine AS builder

LABEL stage=gobuilder

ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

RUN apk update --no-cache && apk add --no-cache tzdata

WORKDIR /build

ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
COPY ./etc /app/etc
RUN go build -ldflags="-s -w" -o /app/notify notify.go


FROM scratch

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai

WORKDIR /app
COPY --from=builder /app/notify /app/notify
COPY --from=builder /app/etc /app/etc

EXPOSE 8887

CMD ["./notify", "-f", "etc/notify.yaml"]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本项目用于蓝鲸告警配置回调通知

开发框架为:[go-zero](https://go-zero.dev/cn/)
开发框架:[go-zero](https://go-zero.dev/cn/)

当前支持: 钉钉机器人 、飞书机器人

Expand Down Expand Up @@ -94,3 +94,9 @@ BkUrl: # 平台链接用于展示
```bash
./notify -f etc/notify.yaml
```

## 6. Docker启动

```bash
docker run -d -p 8887:8887 --name bk-notify -e BK_URL=http://paas.xxx.com viking602/bk-notify:latest
```
2 changes: 1 addition & 1 deletion etc/notify.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Name: notify
Host: 0.0.0.0
Port: 8887
BkUrl:
BkUrl: ${BK_URL}
2 changes: 1 addition & 1 deletion notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
logx.DisableStat()

var c config.Config
conf.MustLoad(*configFile, &c)
conf.MustLoad(*configFile, &c, conf.UseEnv())

server := rest.MustNewServer(c.RestConf)
defer server.Stop()
Expand Down

0 comments on commit c67bba0

Please sign in to comment.