From 19096027ef41a7c386c716ad7b7d2b872b48aceb Mon Sep 17 00:00:00 2001 From: yeqing Date: Wed, 7 Jul 2021 15:19:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20docker=20buildx=20buil?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go-wecomchan/Dockerfile.architecture | 23 +++++++++++++++++++++++ go-wecomchan/README.md | 9 +++++++++ 2 files changed, 32 insertions(+) create mode 100644 go-wecomchan/Dockerfile.architecture diff --git a/go-wecomchan/Dockerfile.architecture b/go-wecomchan/Dockerfile.architecture new file mode 100644 index 0000000..a86d9f8 --- /dev/null +++ b/go-wecomchan/Dockerfile.architecture @@ -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"] diff --git a/go-wecomchan/README.md b/go-wecomchan/README.md index 1b8aee4..b1fe4a4 100644 --- a/go-wecomchan/README.md +++ b/go-wecomchan/README.md @@ -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` From 81b803269f3bb557d682bcefb685f8fd14f7b2d6 Mon Sep 17 00:00:00 2001 From: AceAttorney Date: Wed, 7 Jul 2021 15:28:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go-wecomchan/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/go-wecomchan/README.md b/go-wecomchan/README.md index b1fe4a4..546613a 100644 --- a/go-wecomchan/README.md +++ b/go-wecomchan/README.md @@ -103,3 +103,4 @@ docker run -dit -e SENDKEY=set_a_sendkey \ * [x] Dockerfile 打包镜像(不依赖网络环境) * [x] 通过环境变量传递企业微信id,secret等,镜像一次构建多次使用 * [x] docker-compose redis + go-wecomchan 一键部署 +