From 834e07f45f93f29df3b8ef07dd3f311ba133e218 Mon Sep 17 00:00:00 2001 From: wuqinqiang <1185079673@qq.com> Date: Tue, 2 Nov 2021 22:23:41 +0800 Subject: [PATCH 1/3] 1.cont always not nil 2.fix typo --- common/types.go | 2 +- dtmgrpc/dtmgrpc.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/types.go b/common/types.go index e080313..5ba62be 100644 --- a/common/types.go +++ b/common/types.go @@ -165,7 +165,7 @@ func init() { break } } - if cont != nil && len(cont) != 0 { + if len(cont) != 0 { dtmcli.Logf("cont is: \n%s", string(cont)) err := yaml.Unmarshal(cont, &DtmConfig) dtmcli.FatalIfError(err) diff --git a/dtmgrpc/dtmgrpc.proto b/dtmgrpc/dtmgrpc.proto index e6fe971..20e88f9 100644 --- a/dtmgrpc/dtmgrpc.proto +++ b/dtmgrpc/dtmgrpc.proto @@ -15,7 +15,7 @@ service Dtm { rpc RegisterXaBranch(DtmXaBranchRequest) returns (google.protobuf.Empty) {} } -// DtmRequest 发给dtm服务器的消息,响应为Emtpy,error == nil为成功,== Aborted 为失败 == 其他 可以重试 +// DtmRequest 发给dtm服务器的消息,响应为Empty,error == nil为成功,== Aborted 为失败 == 其他 可以重试 message DtmRequest { string Gid = 1; string TransType = 2; From 25fa65c04dcd54057bc6739262e9f563adc6b8cf Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 7 Nov 2021 12:04:44 +0800 Subject: [PATCH 2/3] build: add ldflags to reduce docker image size --- helper/Dockerfile-release | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helper/Dockerfile-release b/helper/Dockerfile-release index 73a7975..5b99c57 100644 --- a/helper/Dockerfile-release +++ b/helper/Dockerfile-release @@ -4,10 +4,10 @@ RUN go env -w GO111MODULE=on # RUN go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct EXPOSE 8080 COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build app/main.go +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" app/main.go FROM alpine:3.14 as runner COPY --from=builder /app/dtm/main /app/dtm/ ENV IS_DOCKER=1 WORKDIR /app/dtm -CMD ["/app/dtm/main", "dtmsvr"] \ No newline at end of file +CMD ["/app/dtm/main", "dtmsvr"] From ef763d5e21ca7bcb6fd2e94a2f3992684527f67a Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 7 Nov 2021 13:25:28 +0800 Subject: [PATCH 3/3] build: remove go env GO111MODULUES, add upx to reduce image size --- helper/Dockerfile-release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/Dockerfile-release b/helper/Dockerfile-release index 5b99c57..6a0db95 100644 --- a/helper/Dockerfile-release +++ b/helper/Dockerfile-release @@ -1,10 +1,10 @@ FROM golang:1.16.6-alpine3.14 as builder WORKDIR /app/dtm -RUN go env -w GO111MODULE=on # RUN go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct EXPOSE 8080 COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" app/main.go +RUN apk add upx && upx main FROM alpine:3.14 as runner COPY --from=builder /app/dtm/main /app/dtm/