Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.PHONY: all build build-backend build-frontend build-arm build-amd build-backend-arm build-frontend-arm build-backend-amd build-frontend-amd up down restart dev dev-backend dev-frontend logs clean help

all: build up

# 构建所有Docker镜像
build:
docker-compose build

# 只构建后端服务
build-backend:
docker-compose build koalawiki

# 只构建前端服务
build-frontend:
docker-compose build koalawiki-web

# 构建ARM架构的所有Docker镜像
build-arm:
docker-compose build --build-arg ARCH=arm64

# 构建AMD架构的所有Docker镜像
build-amd:
docker-compose build --build-arg ARCH=amd64

# 构建ARM架构的后端服务
build-backend-arm:
docker-compose build --build-arg ARCH=arm64 koalawiki

# 构建ARM架构的前端服务
build-frontend-arm:
docker-compose build --build-arg ARCH=arm64 koalawiki-web

# 构建AMD架构的后端服务
build-backend-amd:
docker-compose build --build-arg ARCH=amd64 koalawiki

# 构建AMD架构的前端服务
build-frontend-amd:
docker-compose build --build-arg ARCH=amd64 koalawiki-web

# 启动所有服务
up:
docker-compose up -d

# 停止所有服务
down:
docker-compose down

# 重启所有服务
restart: down up

# 启动开发环境(非后台模式,可以看到日志输出)
dev:
docker-compose up

# 只启动后端开发环境
dev-backend:
docker-compose up koalawiki

# 只启动前端开发环境
dev-frontend:
docker-compose up koalawiki-web

# 查看服务日志
logs:
docker-compose logs -f

# 清理所有Docker资源(慎用)
clean:
docker-compose down --rmi all --volumes --remove-orphans

# 显示帮助信息
help:
@echo "使用方法:"
@echo " make build - 构建所有Docker镜像"
@echo " make build-backend - 只构建后端服务"
@echo " make build-frontend - 只构建前端服务"
@echo " make build-arm - 构建ARM架构的所有镜像"
@echo " make build-amd - 构建AMD架构的所有镜像"
@echo " make build-backend-arm - 构建ARM架构的后端服务"
@echo " make build-frontend-arm - 构建ARM架构的前端服务"
@echo " make build-backend-amd - 构建AMD架构的后端服务"
@echo " make build-frontend-amd - 构建AMD架构的前端服务"
@echo " make up - 启动所有服务(后台模式)"
@echo " make down - 停止所有服务"
@echo " make restart - 重启所有服务"
@echo " make dev - 启动开发环境(非后台模式,可查看日志)"
@echo " make dev-backend - 只启动后端开发环境"
@echo " make dev-frontend - 只启动前端开发环境"
@echo " make logs - 查看服务日志"
@echo " make clean - 清理所有Docker资源(慎用)"
@echo " make help - 显示此帮助信息"

# 默认目标
default: help
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,26 @@ public static IServiceCollection AddPostgreSQLDbContext(this IServiceCollection
IConfiguration configuration)
{

services.AddDataAccess<PostgreSQLContext>(((provider, builder) =>
services.AddDataAccess<PostgreSQLContext>((_, builder) =>
{
builder.UseNpgsql(configuration.GetConnectionString("Default"));

// sql日志不输出控制台
builder.UseLoggerFactory(LoggerFactory.Create(_ => { }));
});


return services;
}

public static IServiceCollection AddPostgreSQLDbContext(this IServiceCollection services,
string connectionString)
{

services.AddDataAccess<PostgreSQLContext>(((provider, builder) =>
{
builder.UseNpgsql(connectionString);

// sql日志不输出控制台
builder.UseLoggerFactory(LoggerFactory.Create(_ => { }));
}));
Expand Down
15 changes: 15 additions & 0 deletions Provider/KoalaWiki.Provider.Sqlite/SqliteApplicationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ public static IServiceCollection AddSqliteDbContext(this IServiceCollection serv
}));


return services;
}
public static IServiceCollection AddSqliteDbContext(this IServiceCollection services,
string connectionString)
{

services.AddDataAccess<SqliteContext>(((provider, builder) =>
{
builder.UseSqlite(connectionString);

// sql日志不输出控制台
builder.UseLoggerFactory(LoggerFactory.Create(_ => { }));
}));


return services;
}
}
129 changes: 87 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,21 @@ git clone https://github.com/AIDotNet/OpenDeepWiki.git
cd OpenDeepWiki
```

Open the `docker-compose.yml` file and modify the following environment variables:
2. Open the `docker-compose.yml` file and modify the following environment variables:
```yaml
version: '3.8'
services:
services:
koalawiki:
image: crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki
environment:
- KOALAWIKI_REPOSITORIES=/repositories
- TaskMaxSizePerUser=5 # The maximum number of documents generated by AI processing for each user
- REPAIR_MERMAID=1 # Whether to carry out Mermaid repair, 1 repair, no repair for the rest
- ChatModel=DeepSeek-V3 # It is necessary to support the model of function
- AnalysisModel= # The analysis model is used to generate the warehouse directory structure, which is very important. The stronger the model, the better the generated directory structure. If it is empty, use the ChatModel
- ChatApiKey=Your APIkey
- LANGUAGE= # Set the generation language to default to "Chinese"
- Endpoint=https://api.token-ai.cn/v1
volumes:
- ./repositories:/app/repositories
- ./data:/data
build:
context: .
dockerfile: src/KoalaWiki/Dockerfile

koalawiki-web:
image: crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki-web
environment:
- NEXT_PUBLIC_API_URL=http://koalawiki:8080 # 用于提供给server的地址
build:
context: ./web
dockerfile: Dockerfile

nginx: # 需要nginx将前端和后端代理到一个端口
image: nginx:alpine
ports:
- 8090:80
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- koalawiki
- koalawiki-web
- TASK_MAX_SIZE_PER_USER=5 # Maximum parallel tasks for AI document generation per user
- REPAIR_MERMAID=1 # Whether to repair Mermaid, 1 for repair, others for no repair
- CHAT_MODEL=DeepSeek-V3 # Model must support functions
- ANALYSIS_MODEL= # Analysis model for generating repository directory structure
- CHAT_API_KEY= # Your API key
- LANGUAGE= # Default language for generation set to "Chinese"
- ENDPOINT=https://api.token-ai.cn/v1
- DB_TYPE=sqlite
- DB_CONNECTION_STRING=Data Source=/data/KoalaWiki.db
```

> 💡 **How to get an API Key:**
Expand All @@ -80,12 +56,62 @@ version: '3.8'
> - Get CoresHub [CoresHub](https://console.coreshub.cn/xb3/maas/global-keys) [Click here for 50 million free tokens](https://account.coreshub.cn/signup?invite=ZmpMQlZxYVU=)
> - Get TokenAI [TokenAI](https://api.token-ai.cn/)

2. Start the service
3. Start the service

You can use the provided Makefile commands to easily manage the application:

```bash
# Build all Docker images
make build

# Start all services in background mode
make up

# Or start in development mode (with logs visible)
make dev
```

Then visit http://localhost:80 to access the knowledge base.

For more commands:
```bash
make help
```

### For Windows Users (without make)

If you're using Windows and don't have `make` available, you can use these Docker Compose commands directly:

```bash
# Build all Docker images
docker-compose build

# Start all services in background mode
docker-compose up -d

# Start in development mode (with logs visible)
docker-compose up

# Stop all services
docker-compose down

# View logs
docker-compose logs -f
```

For building specific architectures or services, use:

```bash
# Build only backend
docker-compose build koalawiki

# Build only frontend
docker-compose build koalawiki-web

# Build with architecture parameters
docker-compose build --build-arg ARCH=arm64
docker-compose build --build-arg ARCH=amd64
```
Then visit http://localhost:8090 to access the knowledge base

## 🔍 How It Works

Expand Down Expand Up @@ -115,13 +141,32 @@ graph TD

### Environment Variables
- KOALAWIKI_REPOSITORIES # Path for storing repositories
- TaskMaxSizePerUser # Maximum parallel tasks for AI document generation per user
- TASK_MAX_SIZE_PER_USER # Maximum parallel tasks for AI document generation per user
- REPAIR_MERMAID # Whether to repair Mermaid, 1 for repair, others for no repair
- ChatModel # Model must support functions
- Endpoint # API Endpoint
- AnalysisModel # Analysis model for generating repository directory structure, very important, stronger models yield better directory structures, empty uses ChatModel
- ChatApiKey # Your API key
- CHAT_MODEL # Model must support functions
- ENDPOINT # API Endpoint
- ANALYSIS_MODEL # Analysis model for generating repository directory structure
- CHAT_API_KEY # Your API key
- LANGUAGE # Change the language of the generated documents
- DB_TYPE # Database type, default is sqlite
- DB_CONNECTION_STRING # Database connection string

### Build for Different Architectures
The Makefile provides commands to build for different CPU architectures:

```bash
# Build for ARM architecture
make build-arm

# Build for AMD architecture
make build-amd

# Build only backend for ARM
make build-backend-arm

# Build only frontend for AMD
make build-frontend-amd
```

## WeChat

Expand Down
Loading