feat: add Dockerfile and update README with Docker usage instructions

This commit is contained in:
mlogclub
2026-05-23 22:50:07 +08:00
parent c80bae5106
commit 5e0d479640
3 changed files with 94 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
.git
.gitmodules
.DS_Store
.idea
.vscode
.worktrees
.superpowers
Dockerfile
dist
data
qdrant
*.log
__debug_bin*
config/config.yaml
node_modules
.pnpm-store
web/node_modules
web/.next
web/out
web/coverage
web/tsconfig.tsbuildinfo
web/next-env.d.ts
web/.env*
!web/.env.example
+50
View File
@@ -0,0 +1,50 @@
# syntax=docker/dockerfile:1.7
FROM node:24-alpine AS web-builder
WORKDIR /src/web
RUN corepack enable && corepack prepare pnpm@10.30.2 --activate
COPY web/package.json web/pnpm-lock.yaml web/pnpm-workspace.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
COPY web/ ./
RUN pnpm build:sdk && pnpm build
FROM golang:1.26-alpine AS server-builder
WORKDIR /src
RUN apk add --no-cache git
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . ./
COPY --from=web-builder /src/web/out ./web/out
ARG TARGETOS=linux
ARG TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -v -trimpath -ldflags="-s -w" -o /out/cs-agent ./cmd/server
FROM alpine:3.22 AS app
WORKDIR /app
ENV TZ=Asia/Shanghai
RUN apk add --no-cache ca-certificates tzdata wget \
&& mkdir -p /app/config /app/data/storage
COPY --from=server-builder /out/cs-agent /app/cs-agent
COPY config/config.example.yaml /app/config/config.example.yaml
COPY config/config.example.yaml /app/config/config.yaml
EXPOSE 8083
VOLUME ["/app/data"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD wget -qO- http://127.0.0.1:8083/ >/dev/null || exit 1
CMD ["/app/cs-agent", "-config", "/app/config/config.yaml"]
+16
View File
@@ -278,6 +278,22 @@ make enums # 生成前端枚举
make migration # 执行 migration
```
## Docker
```bash
docker build -t cs-agent .
docker run --rm -p 8083:8083 -v cs-agent-data:/app/data cs-agent
```
容器默认使用 `/app/config/config.yaml`,镜像内会基于 `config/config.example.yaml` 放置一份默认配置。生产环境建议通过挂载配置文件覆盖:
```bash
docker run --rm -p 8083:8083 \
-v $(pwd)/config/config.yaml:/app/config/config.yaml:ro \
-v cs-agent-data:/app/data \
cs-agent
```
## 系统视角
- 管理后台:负责 AI Agent、知识库、客服组、工单与运营配置