chore: reduce the docker image size (#1633)

* chore: reduce the docker image size

* chore: format dockerfile
This commit is contained in:
Kevin Wan
2022-03-11 11:30:21 +08:00
committed by GitHub
parent 4624390e54
commit d6a692971f
3 changed files with 35 additions and 22 deletions

View File

@@ -15,6 +15,8 @@ LABEL stage=gobuilder
ENV CGO_ENABLED 0
ENV GOOS linux
{{if .Chinese}}ENV GOPROXY https://goproxy.cn,direct
{{end}}{{if .HasTimezone}}
RUN apk update --no-cache && apk add --no-cache tzdata
{{end}}
WORKDIR /build
@@ -28,9 +30,10 @@ COPY . .
FROM alpine
RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata
ENV TZ Asia/Shanghai
RUN apk update --no-cache && apk add --no-cache ca-certificates
{{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 --from=builder /app/etc /app/etc{{end}}