35 lines
844 B
Docker
35 lines
844 B
Docker
FROM golang:1.25 AS builder
|
|
|
|
ENV GOPROXY=https://proxy.golang.com.cn,https://goproxy.cn,direct \
|
|
GOSUMDB=sum.golang.google.cn \
|
|
CGO_ENABLED=0 \
|
|
GOOS=linux \
|
|
GOARCH=amd64
|
|
|
|
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
|
|
|
|
COPY . .
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
go build -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"]
|