feat: add LanceDB support with Docker integration and configuration files
This commit is contained in:
@@ -11,6 +11,8 @@ docker-data
|
|||||||
dist
|
dist
|
||||||
data
|
data
|
||||||
qdrant
|
qdrant
|
||||||
|
include
|
||||||
|
lib
|
||||||
*.log
|
*.log
|
||||||
__debug_bin*
|
__debug_bin*
|
||||||
|
|
||||||
|
|||||||
+58
@@ -29,6 +29,64 @@ RUN --mount=type=cache,target=/go/pkg/mod \
|
|||||||
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
|
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
|
||||||
go build -v -trimpath -ldflags="-s -w" -o /out/agent-desk ./cmd/server
|
go build -v -trimpath -ldflags="-s -w" -o /out/agent-desk ./cmd/server
|
||||||
|
|
||||||
|
FROM golang:1.26-bookworm AS server-builder-lancedb
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
ARG TARGETOS=linux
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG LANCEDB_VERSION=v0.1.2
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends bash build-essential ca-certificates curl git \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
set -eux; \
|
||||||
|
if [ "$${TARGETOS}" != "linux" ]; then \
|
||||||
|
echo "LanceDB Docker image supports TARGETOS=linux only, got $${TARGETOS}" >&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
arch="$${TARGETARCH:-$$(go env GOARCH)}"; \
|
||||||
|
case "$$arch" in \
|
||||||
|
amd64|arm64) ;; \
|
||||||
|
*) echo "Unsupported LanceDB Docker architecture: $$arch" >&2; exit 1 ;; \
|
||||||
|
esac; \
|
||||||
|
curl -sSL https://raw.githubusercontent.com/lancedb/lancedb-go/main/scripts/download-artifacts.sh | bash -s "$${LANCEDB_VERSION}"; \
|
||||||
|
CGO_ENABLED=1 GOOS="$${TARGETOS}" GOARCH="$$arch" \
|
||||||
|
CGO_CFLAGS="-I/src/include" \
|
||||||
|
CGO_LDFLAGS="/src/lib/linux_$$arch/liblancedb_go.a -lm -ldl -lpthread" \
|
||||||
|
go build -tags lancedb -v -trimpath -ldflags="-s -w" -o /out/agent-desk ./cmd/server
|
||||||
|
|
||||||
|
FROM debian:bookworm-slim AS app-lancedb
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends ca-certificates tzdata wget \
|
||||||
|
&& mkdir -p /app/config /app/data/storage /app/data/lancedb \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY --from=server-builder-lancedb /out/agent-desk /app/agent-desk
|
||||||
|
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/agent-desk", "-config", "/app/config/config.yaml"]
|
||||||
|
|
||||||
FROM alpine:3.22 AS app
|
FROM alpine:3.22 AS app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ SPA_INDEX := $(WEB_DIR)/out/index.html
|
|||||||
|
|
||||||
GO ?= go
|
GO ?= go
|
||||||
PNPM ?= pnpm
|
PNPM ?= pnpm
|
||||||
|
DOCKER ?= docker
|
||||||
GOOS ?= $(shell $(GO) env GOOS)
|
GOOS ?= $(shell $(GO) env GOOS)
|
||||||
GOARCH ?= $(shell $(GO) env GOARCH)
|
GOARCH ?= $(shell $(GO) env GOARCH)
|
||||||
DEV_SERVER_URL ?= http://127.0.0.1:8083
|
DEV_SERVER_URL ?= http://127.0.0.1:8083
|
||||||
LANCEDB_VERSION ?= v0.1.2
|
LANCEDB_VERSION ?= v0.1.2
|
||||||
LANCEDB_DOWNLOAD_SCRIPT ?= https://raw.githubusercontent.com/lancedb/lancedb-go/main/scripts/download-artifacts.sh
|
LANCEDB_DOWNLOAD_SCRIPT ?= https://raw.githubusercontent.com/lancedb/lancedb-go/main/scripts/download-artifacts.sh
|
||||||
LANCEDB_TEST_PKGS ?= ./internal/ai/rag/vectordb
|
LANCEDB_TEST_PKGS ?= ./internal/ai/rag/vectordb
|
||||||
|
LANCEDB_DOCKER_IMAGE ?= mlogclub/agent-desk:lancedb
|
||||||
|
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
UNAME_M := $(shell uname -m)
|
UNAME_M := $(shell uname -m)
|
||||||
@@ -60,7 +62,7 @@ LANCEDB_CGO_LDFLAGS := $(LANCEDB_NATIVE_LIB) $(LANCEDB_SYSTEM_LDFLAGS)
|
|||||||
.PHONY: all help build build-go build-linux release run run-go dev test check clean clean-web \
|
.PHONY: all help build build-go build-linux release run run-go dev test check clean clean-web \
|
||||||
web-install web-dev web-build-spa ensure-spa build-spa web-build-ssr web-typecheck web-lint \
|
web-install web-dev web-build-spa ensure-spa build-spa web-build-ssr web-typecheck web-lint \
|
||||||
generator enums migration testdata lancedb-platform-info lancedb-artifacts lancedb-check \
|
generator enums migration testdata lancedb-platform-info lancedb-artifacts lancedb-check \
|
||||||
build-lancedb test-lancedb clean-lancedb-artifacts
|
build-lancedb test-lancedb clean-lancedb-artifacts docker-build-lancedb
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
@@ -89,6 +91,7 @@ help:
|
|||||||
@echo " make lancedb-artifacts Download LanceDB native libraries for this platform"
|
@echo " make lancedb-artifacts Download LanceDB native libraries for this platform"
|
||||||
@echo " make build-lancedb Build Go binary with LanceDB provider enabled"
|
@echo " make build-lancedb Build Go binary with LanceDB provider enabled"
|
||||||
@echo " make test-lancedb Run LanceDB provider tests with native libraries"
|
@echo " make test-lancedb Run LanceDB provider tests with native libraries"
|
||||||
|
@echo " make docker-build-lancedb Build Docker image with LanceDB provider enabled"
|
||||||
|
|
||||||
build: web-build-spa
|
build: web-build-spa
|
||||||
@$(MAKE) build-go
|
@$(MAKE) build-go
|
||||||
@@ -222,3 +225,10 @@ test-lancedb: lancedb-check
|
|||||||
|
|
||||||
clean-lancedb-artifacts:
|
clean-lancedb-artifacts:
|
||||||
@rm -rf lib include
|
@rm -rf lib include
|
||||||
|
|
||||||
|
docker-build-lancedb:
|
||||||
|
@$(DOCKER) build \
|
||||||
|
--target app-lancedb \
|
||||||
|
--build-arg LANCEDB_VERSION=$(LANCEDB_VERSION) \
|
||||||
|
-t $(LANCEDB_DOCKER_IMAGE) \
|
||||||
|
.
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:8.4
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: cs_ai_agent
|
||||||
|
MYSQL_USER: cs_ai_agent
|
||||||
|
MYSQL_PASSWORD: cs_ai_agent_password
|
||||||
|
MYSQL_ROOT_PASSWORD: cs_ai_agent_root_password
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
command:
|
||||||
|
- --character-set-server=utf8mb4
|
||||||
|
- --collation-server=utf8mb4_unicode_ci
|
||||||
|
volumes:
|
||||||
|
- mysql-data:/var/lib/mysql
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -u\"$${MYSQL_USER}\" -p\"$${MYSQL_PASSWORD}\" --silent"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
agent-desk:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
target: app-lancedb
|
||||||
|
args:
|
||||||
|
LANCEDB_VERSION: v0.1.2
|
||||||
|
image: mlogclub/agent-desk:lancedb
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
ports:
|
||||||
|
- "8083:8083"
|
||||||
|
volumes:
|
||||||
|
- agent-desk-data:/app/data
|
||||||
|
- ./docker/agent-desk-lancedb.yaml:/app/config/config.yaml:ro
|
||||||
|
environment:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql-data:
|
||||||
|
agent-desk-data:
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
server:
|
||||||
|
port: 8083
|
||||||
|
cors:
|
||||||
|
allowedOrigins:
|
||||||
|
- http://localhost:8083
|
||||||
|
- http://127.0.0.1:8083
|
||||||
|
|
||||||
|
db:
|
||||||
|
type: mysql
|
||||||
|
dsn: cs_ai_agent:cs_ai_agent_password@tcp(mysql:3306)/cs_ai_agent?charset=utf8mb4&parseTime=True&loc=Local
|
||||||
|
|
||||||
|
logger:
|
||||||
|
level: info
|
||||||
|
format: text
|
||||||
|
addSource: false
|
||||||
|
|
||||||
|
auth:
|
||||||
|
tokenTTLHours: 24
|
||||||
|
maxFailedAttempts: 5
|
||||||
|
credentialLockMinute: 30
|
||||||
|
|
||||||
|
storage:
|
||||||
|
default: local
|
||||||
|
maxUploadSizeMB: 5
|
||||||
|
local:
|
||||||
|
root: /app/data/storage
|
||||||
|
baseUrl: /storage
|
||||||
|
oss:
|
||||||
|
endpoint: ""
|
||||||
|
bucket: ""
|
||||||
|
accessKeyId: ""
|
||||||
|
accessKeySecret: ""
|
||||||
|
baseUrl: ""
|
||||||
|
private: false
|
||||||
|
signedUrlExpireSeconds: 600
|
||||||
|
|
||||||
|
vectorDB:
|
||||||
|
type: lancedb
|
||||||
|
qdrant:
|
||||||
|
host: qdrant
|
||||||
|
grpcPort: 6334
|
||||||
|
apiKey: ""
|
||||||
|
useTls: false
|
||||||
|
lancedb:
|
||||||
|
path: /app/data/lancedb
|
||||||
|
|
||||||
|
mcp:
|
||||||
|
enabled: true
|
||||||
|
servers:
|
||||||
|
system:
|
||||||
|
enabled: true
|
||||||
|
endpoint: http://127.0.0.1:8083/api/mcp
|
||||||
|
timeoutMs: 60000
|
||||||
|
headers: {}
|
||||||
|
|
||||||
|
wxWork:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
oidc:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
customerSession:
|
||||||
|
secret: change-me
|
||||||
|
ttlMinutes: 120
|
||||||
|
refreshThresholdMinutes: 30
|
||||||
Reference in New Issue
Block a user