From 2117b6321cfae68dfe5d3cb8d3a07771854c278d Mon Sep 17 00:00:00 2001 From: q f Date: Wed, 24 Jan 2024 12:30:27 +0000 Subject: [PATCH] Update Dockerfile --- Dockerfile | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 75ca019..4b04672 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,13 @@ -FROM golang:1-alpine as builder - -# RUN apk --no-cache --no-progress add git ca-certificates tzdata make \ -# && update-ca-certificates \ -# && rm -rf /var/cache/apk/* - -WORKDIR /go/whoami - -# Download go modules -COPY go.mod . -COPY go.sum . - -RUN go env -w GOPROXY=https://goproxy.cn,direct -# RUN GO111MODULE=on GOPROXY=https://proxy.golang.org go mod download +FROM golang:alpine as builder +WORKDIR /app COPY . . -RUN make build +RUN go env -w GOPROXY=https://goproxy.cn,direct +RUN go mod tidy +RUN go build -o whoami -# Create a minimal container to run a Golang static binary FROM scratch - -COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=builder /go/whoami/whoami . - +COPY --from=builder /app/whoami . ENTRYPOINT ["/whoami"] EXPOSE 80