Skip to content

zgsm-sangfor/zgsm-backend-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Costrict Backend Deployment Tool

License Docker Docker Compose

Project Overview

Costrict Backend Deployment Tool is an enterprise-level AI code assistant backend service deployment solution based on Docker Compose. This project provides a complete microservice architecture, including core components such as AI gateway, identity authentication, code analysis, and chat services, supporting both private deployment and cloud service modes.

Core Features

  • Microservice Architecture: Containerized distributed service architecture
  • AI Gateway Integration: Support for multiple large language model access
  • Identity Authentication System: Integrated with Casdoor for enterprise-level identity management
  • Intelligent Code Analysis: Provides code review, completion, optimization and other functions
  • Scalable Design: Support for horizontal scaling and custom plugins

System Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│  VSCode Plugin  │────│   API Gateway   │────│ Backend Services│
│   (Costrict)    │    │ (Apache APISIX) │    │ (Microservices) │
└─────────────────┘    └─────────────────┘    └─────────────────┘
                               │                        │
                        ┌─────────────────┐    ┌─────────────────┐
                        │   AI Gateway    │    │ Database Cluster│
                        │   (Higress)     │    │   (PostgreSQL)  │
                        └─────────────────┘    └─────────────────┘

System Requirements

Model Requirements

The core functions of costrict all depend on large language models, and the following model services need to be prepared in total:

1. Chat model (providing complete http://chat_model_ip:chat_model_port/v1/chat/completions interface)
2. Code review model (providing complete http://review_model_ip:review_model_port/v1/chat/completions interface)
3. Embedding model (providing complete http://embedding_model_ip:embedding_model_port/v1/embeddings interface)
4. Rerank model (providing complete http://rerank_model_ip:rerank_model_port/v1/rerank interface)
5. Completion model (providing complete http://completion_model_ip:completion_model_port/v1/completions interface)

Note: Provide and record accurate model names, APIKEYs, and context size information. Used for configuration during service deployment.

Recommended models and download addresses:

Chat model: GLM-4.5-FP8, GLM-4.5-106B-A12B-FP8

Code review model: Qwen2.5-Coder-32B-Instruct

Completion model: DeepSeek-Coder-V2-Lite-Base

Embedding model: gte-modernbert-baseRAG/Embedding

Rerank model: gte-reranker-modernbert-baseRAG/Rerank

Download addresses:

https://modelscope.cn/models/ZhipuAI/GLM-4.5-FP8
https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air-FP8
https://modelscope.cn/models/Qwen/Qwen2.5-Coder-32B-Instruct
https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct
https://modelscope.cn/models/deepseek-ai/DeepSeek-Coder-V2-Lite-Base
https://modelscope.cn/models/iic/gte-modernbert-base
https://modelscope.cn/models/iic/gte-reranker-modernbert-base

Self-deployed Model Instance Environment

Hardware Requirements:

  • CPU: Intel x64 architecture, minimum 16 cores
  • Memory: Minimum 32GB RAM
  • Storage: Minimum 512GB available storage space
  • GPU: CUDA-enabled graphics card

Software Requirements:

  • Operating System: CentOS 7+ or Ubuntu 18.04+ (WSL supported)
  • Container Runtime: Docker 20.10+
  • Orchestration Tool: Docker Compose 2.0+
  • NVIDIA Driver: nvidia-docker support

Third-party API Service Environment

Hardware Requirements:

  • CPU: Intel x64 architecture, minimum 16 cores
  • Memory: Minimum 32GB RAM
  • Storage: Minimum 512GB available storage space

Software Requirements:

  • Operating System: CentOS 7+ or Ubuntu 18.04+
  • Container Runtime: Docker 20.10+ (refer to Offline Docker Installation for offline installation)
  • Orchestration Tool: Docker Compose 2.0+

Deployment Checklist

Before starting the deployment, please simultaneously open and view the Deployment Checklist and complete all items throughout the deployment process to ensure a successful final deployment.

Quick Start

1. Get Deployment Code

git clone https://github.com/zgsm-ai/zgsm-backend-deploy.git
cd zgsm-backend-deploy

2. Environment Configuration

Edit the configuration file:

vim configure.sh

Key Configuration Parameters:

Parameter Name Description Default Value Required
COSTRICT_BACKEND_BASEURL Backend service base URL -
COSTRICT_BACKEND Backend service host address -
PORT_APISIX_ENTRY API gateway entry port 9080
PORT_HIGRESS_CONTROL Higress console port 8001
PORT_CASDOOR Casdoor authentication system port 9009

Model Settings:

Parameter Name Description Default Value Required
CHAT_MODEL_HOST IP+PORT of chat model -
CHAT_BASEURL Access address of chat model -
CHAT_DEFAULT_MODEL Name of chat model -
CHAT_MODEL_CONTEXTSIZE Context length of chat model -
CHAT_MODEL_DESC Description of chat model -
CHAT_APIKEY APIKEY of chat model, required if the model enables APIKEY authentication -
CODEREVIEW_MODEL_HOST IP+PORT of Codereview model -
CODEREVIEW_BASEURL Access address of Codereview model -
CODEREVIEW_MODEL Name of Codereview model -
CODEREVIEW_MODEL_CONTEXTSIZE Context length of Codereview model -
CODEREVIEW_MODEL_DESC Description of Codereview model -
CODEREVIEW_APIKEY APIKEY of Codereview model, required if the model enables APIKEY authentication -
COMPLETION_BASEURL Access address of code completion model -
COMPLETION_MODEL Name of code completion model -
COMPLETION_APIKEY APIKEY of code completion model, required if the model enables APIKEY authentication -
EMBEDDER_BASEURL Access address of vector embedding model -
EMBEDDER_MODEL Name of vector embedding model -
EMBEDDER_APIKEY APIKEY of vector embedding model, required if the model enables APIKEY authentication -
RERANKER_BASEURL Access address of rerank model -
RERANKER_MODEL Name of rerank model -
RERANKER_APIKEY APIKEY of rerank model, required if the model enables APIKEY authentication -

Note: Code completion, vector embedding, and rerank models are for internal use by Costrict only and will not appear in the user-selectable model list.

3. Prepare Backend Service Images

Costrict backend images are mainly stored in the docker hub image repository docker.io/zgsm.

Before deployment, you need to ensure that the images required for backend deployment can be pulled from the image repository normally.

The images required by Costrict backend can be found in the scripts/newest-images.list file for a complete list.

You can get this list file from the cloud with the following command.

bash scripts/get-images-list.sh -o scripts

The deployment script will automatically pull all images required for backend deployment during the deployment process.

However, if the deployment server cannot access the docker hub image repository, you need to download the images in advance and save them to the specified directory of the deployment machine (assuming saved in /root/images). Then run the following command to preload them.

bash scripts/load-images.sh -l /root/images

In addition to pulling and exporting image files from the docker image repository, you can also download all image files required for Costrict backend deployment from Baidu Netdisk.

Netdisk address:

https://pan.baidu.com/s/12kP5VyQinFNrXFsKEWFGJw?pwd=k2dh

4. Service Deployment

Execute the automated deployment script:

bash deploy.sh

The deployment process includes the following steps:

  1. Environment check and dependency verification
  2. Docker image pulling and building
  3. Database initialization
  4. Service container startup
  5. Health check and status verification

Service Configuration

AI Gateway Configuration (Higress)

After deployment, access the Higress console at the following address to configure the chat and code review models:

http://{COSTRICT_BACKEND}:{PORT_HIGRESS_CONTROL}

Default admin username and password (please change it after login):

Username: admin
Password: test123

Configuration steps:

  1. Access the Higress management interface
  2. Configure upstream LLM service providers
  3. Set routing rules and load balancing strategies
  4. Configure rate limiting and security policies

Detailed configuration guide: Higress Configuration Document

Optional: Identity Authentication System Configuration (Casdoor)

Access the Casdoor management interface at the following address:

http://{COSTRICT_BACKEND}:{PORT_CASDOOR}

Test Account (for development and testing environments only):

Username: demo
Password: test123

Configuration features:

  • User management and permission control
  • Third-party identity provider integration (OIDC/SAML)
  • Multi-factor authentication (MFA)
  • Session management and security policies

Detailed configuration guide: Casdoor Configuration Document

Client Integration

VSCode Plugin Configuration

  1. Install the Costrict VSCode extension
  2. Open the "Provider" page in the extension settings
  3. Select the API provider as "Costrict"
  4. Configure the backend service address:
    Costrict Base URL: {COSTRICT_BACKEND_BASEURL}
    
  5. Click "Login Costrict" to complete authentication

Service Access Address:

Default backend entry: http://{COSTRICT_BACKEND}:{PORT_APISIX_ENTRY}

Domain Binding and Load Balancing

For production environments, it is recommended to access services through reverse proxy or load balancer:

# Nginx configuration example
upstream costrict_backend {
    server {COSTRICT_BACKEND}:{PORT_APISIX_ENTRY};
}

server {
    listen 443 ssl;
    server_name your-domain.com;
    
    location / {
        proxy_pass http://costrict_backend;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Operations Management

Service Status Monitoring

Check service running status:

# View all service status
docker-compose ps

# View service logs
docker-compose logs -f [service_name]

# View resource usage
docker stats

Data Backup and Recovery

# Database backup
bash ./scripts/backup.sh

# Database recovery
bash ./scripts/restore.sh [backup_file]

Service Scaling

# Scale service instances
docker-compose up -d --scale chatgpt=3

# Update service configuration
docker-compose up -d --force-recreate [service_name]

Troubleshooting

Common Issues

1. Container startup failure

# Check port occupancy
netstat -tlnp | grep {port}

# Check disk space
df -h

# View detailed error logs
docker-compose logs [service_name]

2. Network connection issues

# Test service connectivity
curl -v http://{COSTRICT_BACKEND}:{PORT_APISIX_ENTRY}/health

# Check Docker network
docker network ls
docker network inspect {network_name}

3. Database connection issues

# Check database service status
docker-compose exec postgres pg_isready

# View database logs
docker-compose logs postgres

Log Collection

System log locations:

  • Application logs: ./logs/
  • Database logs: /var/log/postgresql/ inside container
  • Gateway logs: /var/log/apisix/ inside container

Security Notes

  1. Production Environment Deployment:

    • Change all default passwords
    • Configure HTTPS certificates
    • Enable firewall and access control
    • Regularly update systems and dependencies
  2. Network Security:

    • Only open necessary ports
    • Configure VPN or intranet access
    • Enable API rate limiting and protection
  3. Data Protection:

    • Regularly backup important data
    • Enable database encryption
    • Configure access audit logs

License

This project is open source under the Apache 2.0 license. See the LICENSE file for details.

Support and Contribution


Costrict - Let AI power your code development journey

About

Used for deploying the backend service of ZGSM

Resources

Stars

17 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors