2026-01-12 18:14:32 +08:00
|
|
|
FROM golang:1.23.4-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
|
|
|
|
|
|
|
|
|
|
ADD go.mod .
|
|
|
|
|
ADD go.sum .
|
|
|
|
|
RUN go mod download
|
|
|
|
|
COPY . .
|
|
|
|
|
COPY app/main/api/etc /app/etc
|
|
|
|
|
COPY app/main/api/static /app/static
|
|
|
|
|
RUN go build -ldflags="-s -w" -o /app/main app/main/api/main.go
|
|
|
|
|
|
|
|
|
|
|
2026-01-13 15:18:30 +08:00
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
|
|
RUN apk add --no-cache ca-certificates tzdata netcat-openbsd
|
2026-01-12 18:14:32 +08:00
|
|
|
|
|
|
|
|
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
|
|
|
|
|
ENV TZ Asia/Shanghai
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
COPY --from=builder /app/main /app/main
|
|
|
|
|
COPY --from=builder /app/etc /app/etc
|
|
|
|
|
COPY --from=builder /app/static /app/static
|
|
|
|
|
|
2026-01-13 15:18:30 +08:00
|
|
|
ENTRYPOINT ["./main"]
|
|
|
|
|
CMD ["-f", "etc/main.yaml"]
|