Dockerfile 673 B

123456789101112131415161718192021222324252627282930
  1. FROM golang:alpine AS builder
  2. LABEL stage=gobuilder
  3. ENV CGO_ENABLED 0
  4. ENV GOPROXY https://goproxy.cn,direct
  5. RUN apk update --no-cache && apk add --no-cache tzdata
  6. WORKDIR /build
  7. ADD go.mod .
  8. ADD go.sum .
  9. RUN go mod download
  10. COPY . .
  11. COPY core/cmd/rpc/etc /app/etc
  12. RUN go build -ldflags="-s -w" -o /app/cmd core/cmd/rpc/cmd.go
  13. FROM scratch
  14. COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
  15. COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
  16. ENV TZ Asia/Shanghai
  17. WORKDIR /app
  18. COPY --from=builder /app/cmd /app/cmd
  19. COPY --from=builder /app/etc /app/etc
  20. CMD ["./cmd", "-f", "etc/cmd.yaml"]