Merge pull request #21 from AceAttorney/main

添加Dockerfile.architecture 支持多架构
This commit is contained in:
Easy 2021-07-07 16:02:26 +08:00 committed by GitHub
commit c8d3f08792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,23 @@
FROM --platform=$TARGETPLATFORM 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"]

View File

@ -1,5 +1,13 @@
# go-wecomchan
## what's new
添加 Dockerfile.architecture 使用docker buildx支持构建多架构镜像。
关于docker buildx build 使用方式参考官方文档:
[https://docs.docker.com/engine/reference/commandline/buildx_build/](https://docs.docker.com/engine/reference/commandline/buildx_build/)
## 配置说明
直接使用和构建二进制文件使用需要golang环境并且网络可以安装依赖。
@ -30,6 +38,7 @@ var REDIS_PASSWORD string = GetEnvDefault("REDIS_PASSWORD", "")
`go run .`
## build命令构建二进制文件使用
1. 构建命令
`go build`
@ -94,3 +103,4 @@ docker run -dit -e SENDKEY=set_a_sendkey \
* [x] Dockerfile 打包镜像(不依赖网络环境)
* [x] 通过环境变量传递企业微信idsecret等镜像一次构建多次使用
* [x] docker-compose redis + go-wecomchan 一键部署