From 751867652d1b6bfb15499e5af43033beffc7366b Mon Sep 17 00:00:00 2001 From: AceAttorney Date: Fri, 25 Jun 2021 22:41:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=95=9C=E5=83=8F=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go-wecomchan/Dockerfile | 23 +++++++++++++++++++++++ go-wecomchan/README.md | 27 ++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 go-wecomchan/Dockerfile diff --git a/go-wecomchan/Dockerfile b/go-wecomchan/Dockerfile new file mode 100644 index 0000000..7e487b1 --- /dev/null +++ b/go-wecomchan/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.16.5-alpine3.13 as gobuilder + +ENV GO111MODULE="on" +ENV GOPROXY="https://goproxy.cn,direct" +ENV CGO_ENABLED=0 + +WORKDIR /go/src/app +COPY . . + +RUN apk update && apk upgrade && apk add --no-cache ca-certificates +RUN update-ca-certificates +RUN go build + +FROM scratch + +WORKDIR /root + +COPY --from=gobuilder /go/src/app/wecomchan . +COPY --from=gobuilder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +EXPOSE 8080 + +CMD ["./wecomchan"] diff --git a/go-wecomchan/README.md b/go-wecomchan/README.md index fc6c0af..4ee28ca 100644 --- a/go-wecomchan/README.md +++ b/go-wecomchan/README.md @@ -2,17 +2,34 @@ ## 配置说明 -需要golang环境,并且网络可以安装依赖 +直接使用和构建二进制文件使用需要golang环境,并且网络可以安装依赖。 +docker构建镜像使用,需要安装docker,不依赖golang以及网络。 ## 直接使用 `go run .` -## build命令 - +## build命令构建二进制文件使用 +1. 构建命令 `go build` +2. 启动 +`./wecomchan` + +## 构建docker镜像使用(推荐,不依赖golang,不依赖网络) + +1. 构建镜像 +`docker build -t go-wecomchan .` + +2. 启动镜像 +`docker run -dit -p 8080:8080 go-wecomchan` + +## 调用方式 + +访问 `http://localhost:8080/wecomchan?sendkey=你配置的sendkey&&msg=需要发送的消息&&msg_type=text` + ## 后续预计添加 -- Dockerfile 打包镜像(不依赖网络环境) -- docker-compose redis + go-wecomchan 一键部署 \ No newline at end of file +~~- Dockerfile 打包镜像(不依赖网络环境)~~ +- docker-compose redis + go-wecomchan 一键部署 +- 通过环境变量传递企业微信id,secret等,镜像一次构建多次使用