FROM golang:1.25 AS builder ENV CGO_ENABLED=0 \ GOOS=linux \ GOARCH=amd64 \ GOPROXY=https://goproxy.cn|https://proxy.golang.google.cn|direct \ GOSUMDB=sum.golang.google.cn WORKDIR /src/ai-chat-service COPY go.mod go.sum ./ RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ go mod download -x COPY . . RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ go build -trimpath -ldflags="-s -w" -o /out/ai-chat-service ./chat-server FROM alpine:3.18 ADD ./grpc_health_probe-linux-amd64 /usr/bin/grpc_health_probe RUN chmod +x /usr/bin/grpc_health_probe LABEL maintainer="nick" WORKDIR /app/ COPY --from=builder /out/ai-chat-service ./ai-chat-service COPY ./docker.config.yaml /app/config.yaml ENTRYPOINT ["./ai-chat-service"] CMD ["--config=config.yaml"]