Update Dockerfile

This commit is contained in:
q f 2024-01-24 12:30:27 +00:00
parent 062f69da2b
commit 2117b6321c

View File

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