chore: format Dockerfile template (#4496)

This commit is contained in:
Kevin Wan 2024-12-14 12:38:33 +08:00 committed by GitHub
parent 13746a3706
commit ad291daf78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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}}