From ad291daf787a9e7e1bc9fe17469b72e774e41abf Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sat, 14 Dec 2024 12:38:33 +0800 Subject: [PATCH] chore: format Dockerfile template (#4496) --- tools/goctl/docker/docker.tpl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/goctl/docker/docker.tpl b/tools/goctl/docker/docker.tpl index 98039f01..b897b405 100644 --- a/tools/goctl/docker/docker.tpl +++ b/tools/goctl/docker/docker.tpl @@ -4,10 +4,12 @@ LABEL stage=gobuilder ENV CGO_ENABLED 0 {{if .Chinese}}ENV GOPROXY https://goproxy.cn,direct + RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -{{end}}{{if .HasTimezone}} +{{- end}}{{if .HasTimezone}} RUN apk update --no-cache && apk add --no-cache tzdata -{{end}} +{{- end}} + WORKDIR /build ADD go.mod . @@ -21,14 +23,15 @@ RUN go build -ldflags="-s -w" -o /app/{{.ExeFile}} {{.GoMainFrom}} FROM {{.BaseImage}} COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -{{if .HasTimezone}}COPY --from=builder /usr/share/zoneinfo/{{.Timezone}} /usr/share/zoneinfo/{{.Timezone}} +{{if .HasTimezone -}} +COPY --from=builder /usr/share/zoneinfo/{{.Timezone}} /usr/share/zoneinfo/{{.Timezone}} ENV TZ {{.Timezone}} {{end}} WORKDIR /app COPY --from=builder /app/{{.ExeFile}} /app/{{.ExeFile}} -{{if .Argument}}COPY {{.GoRelPath}}/etc /app/etc -{{end}} - +{{if .Argument -}} +COPY {{.GoRelPath}}/etc /app/etc +{{- end}} {{if .HasPort}} EXPOSE {{.Port}} {{end}}