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..546613a 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` @@ -94,3 +103,4 @@ docker run -dit -e SENDKEY=set_a_sendkey \ * [x] Dockerfile 打包镜像(不依赖网络环境) * [x] 通过环境变量传递企业微信id,secret等,镜像一次构建多次使用 * [x] docker-compose redis + go-wecomchan 一键部署 +