diff --git a/docker/Dockerfile.services b/docker/Dockerfile.services index 703761d..e2da719 100644 --- a/docker/Dockerfile.services +++ b/docker/Dockerfile.services @@ -48,7 +48,10 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" \ echo "Built taskservice" && \ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" \ -o /tmp/starbookservice services/starbookService/main.go && \ - echo "Built starbookservice" + echo "Built starbookservice" && \ + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" \ + -o /tmp/aichatservice services/aiChatService/main.go && \ + echo "Built aichatservice" # ---- Runtime Stage: Gateway ---- FROM --platform=linux/amd64 alpine:3.19 AS gateway @@ -171,3 +174,18 @@ HEALTHCHECK --interval=10s --timeout=5s --start-period=10s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:21005 || exit 1 ENTRYPOINT ["/app/starbookservice"] + +# ---- Runtime Stage: AIChatService ---- +FROM --platform=linux/amd64 alpine:3.19 AS aichatservice + +RUN apk add --no-cache ca-certificates tzdata + +WORKDIR /app +COPY --from=builder /tmp/aichatservice /app/aichatservice + +EXPOSE 20008 + +HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:21008 || exit 1 + +ENTRYPOINT ["/app/aichatservice"] diff --git a/docker/build.sh b/docker/build.sh index 77210bc..c581835 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -77,7 +77,7 @@ while [[ $# -gt 0 ]]; do echo "" echo "服务名 (可选):" echo " gateway, userService, socialService, assetService," - echo " galleryService, activityService, taskService, starbookService" + echo " galleryService, activityService, taskService, starbookService, aiChatService" echo "" echo "示例:" echo " $0 # 构建所有服务" @@ -98,6 +98,7 @@ while [[ $# -gt 0 ]]; do activity|activityService) SERVICES+=("activityService") ;; task|taskService) SERVICES+=("taskService") ;; starbook|starbookService) SERVICES+=("starbookService") ;; + ai|aiChatService|aichatservice) SERVICES+=("aiChatService") ;; all) # all 关键字,构建所有服务 SERVICES=() @@ -116,7 +117,7 @@ done # ==================== 服务列表 ==================== # 所有可用服务及其配置(使用小写 target 名) -ALL_SERVICES_NAME=("gateway" "userservice" "socialservice" "assetservice" "galleryservice" "activityservice" "taskservice" "starbookservice") +ALL_SERVICES_NAME=("gateway" "userservice" "socialservice" "assetservice" "galleryservice" "activityservice" "taskservice" "starbookservice" "aichatservice") # 确定要构建的服务 if [ ${#SERVICES[@]} -eq 0 ]; then @@ -205,6 +206,7 @@ main() { activityservice) docker_target="activityservice" ;; taskservice) docker_target="taskservice" ;; starbookservice) docker_target="starbookservice" ;; + aichatservice) docker_target="aichatservice" ;; # 兼容旧的大写服务名 userService) docker_target="userservice" ;; socialService) docker_target="socialservice" ;; diff --git a/docker/deploy.sh b/docker/deploy.sh index fc4347b..aa7824e 100755 --- a/docker/deploy.sh +++ b/docker/deploy.sh @@ -78,6 +78,7 @@ SERVICES=( "activityservice" "taskservice" "starbookservice" + "aichatservice" ) # ==================== 服务器配置 ==================== diff --git a/docker/docker-compose.local.yml b/docker/docker-compose.local.yml index ad8b523..477c68f 100644 --- a/docker/docker-compose.local.yml +++ b/docker/docker-compose.local.yml @@ -259,6 +259,45 @@ services: reservations: memory: 256M + # ==================== AI Chat Service ==================== + aichatservice: + image: topfans/aichatservice:latest + build: + context: .. + dockerfile: docker/Dockerfile.services + target: aichatservice + container_name: topfans-aichatservice + restart: unless-stopped + environment: + <<: *common-env + PORT: 20008 + DB_HOST: host.docker.internal + DB_PORT: 15432 + REDIS_HOST: host.docker.internal + REDIS_PORT: 6379 + REDIS_DB: 0 + MINIMAX_API_KEY: ${MINIMAX_API_KEY:-} + MINIMAX_API_URL: ${MINIMAX_API_URL:-https://api.minimaxi.com/v1} + MINIMAX_MODEL: ${MINIMAX_MODEL:-M2-her} + QWEN_API_KEY: ${QWEN_API_KEY:-} + QWEN_API_URL: ${QWEN_API_URL:-https://dashscope.aliyuncs.com/compatible-mode/v1} + QWEN_MODEL: ${QWEN_MODEL:-qwen-plus} + extra_hosts: + - "host.docker.internal:host-gateway" + networks: + - topfans-net + expose: + - "20008" + healthcheck: + test: ["CMD-SHELL", "nc -z localhost 20008 || exit 1"] + <<: *healthcheck + deploy: + resources: + limits: + memory: 512M + reservations: + memory: 256M + # ==================== API Gateway ==================== gateway: image: topfans/gateway:latest @@ -279,6 +318,7 @@ services: DUBBO_ACTIVITY_SERVICE_URL: tri://activityservice:20005 DUBBO_TASK_SERVICE_URL: tri://taskservice:20006 DUBBO_STARBOOK_SERVICE_URL: tri://starbookservice:20007 + DUBBO_AI_CHAT_SERVICE_URL: tri://aichatservice:20008 depends_on: userservice: condition: service_healthy @@ -294,6 +334,8 @@ services: condition: service_healthy starbookservice: condition: service_healthy + aichatservice: + condition: service_healthy networks: - topfans-net ports: diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index ce68a68..f5df07d 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -389,6 +389,54 @@ services: memory: 64M cpus: '0.25' + # ==================== AI Chat Service ==================== + aichatservice: + image: topfans/aichatservice:latest + build: + context: .. + dockerfile: docker/Dockerfile.services + target: aichatservice + container_name: topfans-aichatservice + restart: always + environment: + <<: *common-env + PORT: 20008 + DB_HOST: postgres + DB_PORT: 5432 + DB_USER: postgres + DB_PASSWORD: ${DB_PASSWORD:-postgres123} + DB_NAME: topfans + REDIS_HOST: topfans-redis + REDIS_PORT: 6379 + REDIS_PASSWORD: ${REDIS_PASSWORD:-123456} + REDIS_DB: 0 + MINIMAX_API_KEY: ${MINIMAX_API_KEY:-} + MINIMAX_API_URL: ${MINIMAX_API_URL:-https://api.minimaxi.com/v1} + MINIMAX_MODEL: ${MINIMAX_MODEL:-M2-her} + QWEN_API_KEY: ${QWEN_API_KEY:-} + QWEN_API_URL: ${QWEN_API_URL:-https://dashscope.aliyuncs.com/compatible-mode/v1} + QWEN_MODEL: ${QWEN_MODEL:-qwen-plus} + depends_on: + userservice: + condition: service_started + redis: + condition: service_healthy + networks: + - topfans-net + expose: + - "20008" + healthcheck: + test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:21008 || exit 1"] + <<: *healthcheck + deploy: + resources: + limits: + memory: 512M + cpus: '1' + reservations: + memory: 256M + cpus: '0.5' + # ==================== API Gateway ==================== gateway: image: topfans/gateway:latest @@ -411,6 +459,7 @@ services: DUBBO_ACTIVITY_SERVICE_URL: tri://activityservice:20004 DUBBO_TASK_SERVICE_URL: tri://taskservice:20006 DUBBO_STARBOOK_SERVICE_URL: tri://starbookservice:20005 + DUBBO_AI_CHAT_SERVICE_URL: tri://aichatservice:20008 REDIS_HOST: topfans-redis REDIS_PORT: 6379 REDIS_PASSWORD: ${REDIS_PASSWORD:-123456} @@ -430,6 +479,8 @@ services: condition: service_started starbookservice: condition: service_started + aichatservice: + condition: service_started redis: condition: service_healthy networks: diff --git a/frontend/pages/ai-dazi/index.vue b/frontend/pages/ai-dazi/index.vue index 0002439..984cc13 100644 --- a/frontend/pages/ai-dazi/index.vue +++ b/frontend/pages/ai-dazi/index.vue @@ -11,31 +11,31 @@ - + - + - +