compose
This commit is contained in:
5
ai-chat-service/.dockerignore
Normal file
5
ai-chat-service/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
||||
.git
|
||||
.gitignore
|
||||
ai-chat-service-bin
|
||||
runtime/logs
|
||||
runtime/*.log
|
||||
@@ -1,11 +1,34 @@
|
||||
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 ./ai-chat-service-bin ./ai-chat-service
|
||||
|
||||
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"]
|
||||
|
||||
@@ -6,9 +6,9 @@ log:
|
||||
level: "info"
|
||||
logPath: "runtime/logs/app.log"
|
||||
chat:
|
||||
api_key: "sk-8NMdsGbDAMpWdd6hrKHepr1tNVXTy2QppKAqJkoJcHd6TYLs"
|
||||
api_key: "xxxxxxxxxxx"
|
||||
base_url: "https://api.moonshot.cn/v1"
|
||||
model: "kimi-k2.5"
|
||||
model: "kimi-k2-turbo-preview"
|
||||
max_tokens: 4096
|
||||
temperature: 1
|
||||
top_p: 0.95
|
||||
|
||||
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@@ -113,6 +114,7 @@ func InitConfig(filePath string, typ ...string) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
normalizeConfig(conf)
|
||||
applySecretEnvOverrides(conf)
|
||||
|
||||
}
|
||||
|
||||
@@ -167,3 +169,15 @@ func normalizeConfig(conf *Config) {
|
||||
conf.Embedding.Timeout = 10
|
||||
}
|
||||
}
|
||||
|
||||
func applySecretEnvOverrides(conf *Config) {
|
||||
if v := os.Getenv("MOONSHOT_API_KEY"); v != "" {
|
||||
conf.Chat.ApiKey = v
|
||||
}
|
||||
if v := os.Getenv("AI_CHAT_EMBEDDING_API_KEY"); v != "" {
|
||||
conf.Embedding.ApiKey = v
|
||||
}
|
||||
if v := os.Getenv("REDIS_PASSWORD"); v != "" {
|
||||
conf.Redis.Pwd = v
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user