添加 docker buildx build

This commit is contained in:
yeqing 2021-07-07 15:19:09 +08:00
parent ba459a4550
commit 19096027ef
2 changed files with 32 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`