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