Dockerfile 529 B

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