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