From 5ef149678ef2041d506d78668411f2d6cb06e521 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 13 Mar 2022 21:05:06 +0800 Subject: [PATCH] update dockerfile --- stash/{Dockerfile => Dockerfile.amd64} | 10 ++++++---- stash/Dockerfile.arm64 | 11 +++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) rename stash/{Dockerfile => Dockerfile.amd64} (62%) diff --git a/stash/Dockerfile b/stash/Dockerfile.amd64 similarity index 62% rename from stash/Dockerfile rename to stash/Dockerfile.amd64 index ff78e5d..20a6bfc 100644 --- a/stash/Dockerfile +++ b/stash/Dockerfile.amd64 @@ -6,7 +6,9 @@ ENV CGO_ENABLED 0 ENV GOOS linux ENV GOPROXY https://goproxy.cn,direct -WORKDIR /build/zero +RUN apk update --no-cache && apk add --no-cache tzdata + +WORKDIR /build ADD go.mod . ADD go.sum . @@ -14,12 +16,12 @@ RUN go mod download COPY . . COPY stash/etc /app/etc RUN GOARCH=amd64 go build -ldflags="-s -w" -o /app/stash stash/stash.go -RUN apk update --no-cache && apk add upx && upx /app/stash -FROM alpine +FROM scratch -RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai ENV TZ Asia/Shanghai WORKDIR /app diff --git a/stash/Dockerfile.arm64 b/stash/Dockerfile.arm64 index 49a1777..e3edbf7 100644 --- a/stash/Dockerfile.arm64 +++ b/stash/Dockerfile.arm64 @@ -1,4 +1,4 @@ -FROM arm64v8/golang:alpine AS builder +FROM golang:alpine AS builder LABEL stage=gobuilder @@ -6,7 +6,9 @@ ENV CGO_ENABLED 0 ENV GOOS linux ENV GOPROXY https://goproxy.cn,direct -WORKDIR /build/zero +RUN apk update --no-cache && apk add --no-cache tzdata + +WORKDIR /build ADD go.mod . ADD go.sum . @@ -16,9 +18,10 @@ COPY stash/etc /app/etc RUN GOARCH=arm64 go build -ldflags="-s -w" -o /app/stash stash/stash.go -FROM arm64v8/alpine +FROM scratch -RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai ENV TZ Asia/Shanghai WORKDIR /app