添加镜像使用方式
This commit is contained in:
parent
eff0e34975
commit
751867652d
|
@ -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"]
|
|
@ -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 打包镜像(不依赖网络环境)
|
||||
~~- Dockerfile 打包镜像(不依赖网络环境)~~
|
||||
- docker-compose redis + go-wecomchan 一键部署
|
||||
- 通过环境变量传递企业微信id,secret等,镜像一次构建多次使用
|
||||
|
|
Loading…
Reference in New Issue