Dockerfile 657 B

123456789101112131415161718192021222324252627
  1. FROM golang:1.18-alpine AS builder
  2. LABEL stage=gobuilder
  3. ENV CGO_ENABLED 0
  4. ENV GOPROXY https://goproxy.cn,direct
  5. RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
  6. RUN apk update --no-cache && apk add --no-cache tzdata
  7. WORKDIR /build
  8. RUN go mod download
  9. COPY . .
  10. RUN go build -ldflags="-s -w" -o /${APP_NAME} app/cmd/${APP_NAME}/${APP_NAME}.go
  11. FROM scratch
  12. COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
  13. ENV TZ Asia/Shanghai
  14. WORKDIR /
  15. COPY --from=builder /${APP_NAME} /${APP_NAME}
  16. COPY --from=builder /app/cmd/${APP_NAME}/etc /app/etc
  17. CMD ["./events", "-f", "etc/events.yaml"]