Skip to content

Commit eb79ad4

Browse files
committed
docs(quick-start): 添加项目初始化脚本和更新快速入门文档
添加 Bash 和 PowerShell 初始化脚本,用于自动配置环境变量和拉取 Docker 镜像 更新快速入门文档,增加两种初始化方法的说明和 API Key 获取指引
1 parent ff75c2d commit eb79ad4

File tree

3 files changed

+203
-1
lines changed

3 files changed

+203
-1
lines changed

docs/latest/intro/quick-start.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,32 @@ cd Yuxi-Know
2626
- `main`: 最新开发版本(不稳定,新特性可能会导致新 bug)
2727
:::
2828

29-
#### 2. 配置环境变量
29+
#### 2. 项目启动
30+
31+
** 方法 1**:使用 init 脚本(推荐)
32+
33+
我们提供了自动化的初始化脚本,可以帮您完成环境配置和 Docker 镜像拉取:
34+
35+
```bash
36+
# Linux/macOS
37+
./scripts/init.sh
38+
39+
# Windows PowerShell
40+
.\scripts\init.ps1
41+
```
42+
43+
脚本会:
44+
- 检查并创建 `.env` 文件
45+
- 提示您输入 `SILICONFLOW_API_KEY`(必需)
46+
- 提示您输入 `TAVILY_API_KEY`(可选,用于搜索服务)
47+
- 自动拉取所有必需的 Docker 镜像
48+
49+
::: tip API Key 获取
50+
- [硅基流动](https://cloud.siliconflow.cn/i/Eo5yTHGJ) 注册即送 14 元额度
51+
- [Tavily](https://app.tavily.com/) 获取搜索服务 API Key(可选)
52+
:::
53+
54+
** 方法 2**:手动配置环境变量
3055

3156
复制环境变量模板并编辑:
3257

scripts/init.ps1

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Yuxi-Know Initialization Script for PowerShell
2+
# This script helps set up the environment for the Yuxi-Know project
3+
# Note: API keys will be visible during input - use with care
4+
5+
Write-Host "🚀 Initializing Yuxi-Know project..." -ForegroundColor Cyan
6+
Write-Host "==================================" -ForegroundColor Cyan
7+
8+
# Check if .env file exists
9+
if (Test-Path ".env") {
10+
Write-Host "✅ .env file already exists. Skipping environment setup." -ForegroundColor Green
11+
} else {
12+
Write-Host "📝 .env file not found. Let's set up your environment variables." -ForegroundColor Yellow
13+
Write-Host ""
14+
15+
# Get SILICONFLOW_API_KEY
16+
Write-Host "🔑 SiliconFlow API Key required" -ForegroundColor Yellow
17+
Write-Host "Get your API key from: https://cloud.siliconflow.cn/i/Eo5yTHGJ" -ForegroundColor Blue
18+
Write-Host "Note: Press Ctrl+C at any time to cancel" -ForegroundColor Gray
19+
Write-Host ""
20+
21+
do {
22+
$apiKey = Read-Host "Please enter your SILICONFLOW_API_KEY"
23+
if ([string]::IsNullOrEmpty($apiKey)) {
24+
Write-Host "❌ API Key cannot be empty. Please try again." -ForegroundColor Red
25+
}
26+
} while ([string]::IsNullOrEmpty($apiKey))
27+
28+
# Get TAVILY_API_KEY (optional)
29+
Write-Host ""
30+
Write-Host "🔍 Tavily API Key (optional) - for search service" -ForegroundColor Yellow
31+
Write-Host "Get your API key from: https://app.tavily.com/" -ForegroundColor Blue
32+
33+
$TAVILY_API_KEY = Read-Host "Please enter your TAVILY_API_KEY (press Enter to skip)"
34+
35+
# Create .env file
36+
$envContent = @"
37+
# SiliconFlow API Key (required)
38+
SILICONFLOW_API_KEY=$apiKey
39+
40+
# Tavily API Key (optional - for search service)
41+
"@
42+
43+
if (-not [string]::IsNullOrEmpty($TAVILY_API_KEY)) {
44+
$envContent += "TAVILY_API_KEY=$TAVILY_API_KEY"
45+
}
46+
47+
$envContent | Out-File -FilePath ".env" -Encoding UTF8
48+
Write-Host "✅ .env file created successfully!" -ForegroundColor Green
49+
50+
# Clear the variables from memory
51+
Remove-Variable -Name "apiKey" -ErrorAction SilentlyContinue
52+
Remove-Variable -Name "TAVILY_API_KEY" -ErrorAction SilentlyContinue
53+
}
54+
55+
Write-Host ""
56+
Write-Host "📦 Pulling Docker images..." -ForegroundColor Cyan
57+
Write-Host "=========================" -ForegroundColor Cyan
58+
59+
# List of Docker images to pull
60+
$images = @(
61+
"python:3.12-slim",
62+
"node:20-slim",
63+
"node:20-alpine",
64+
"milvusdb/milvus:v2.5.6",
65+
"neo4j:5.26",
66+
"minio/minio:RELEASE.2023-03-20T20-16-18Z",
67+
"ghcr.io/astral-sh/uv:0.7.2",
68+
"nginx:alpine",
69+
"quay.io/coreos/etcd:v3.5.5"
70+
)
71+
72+
# Pull each image
73+
foreach ($image in $images) {
74+
Write-Host "🔄 Pulling ${image}..." -ForegroundColor Yellow
75+
try {
76+
& docker/pull_image.ps1 $image
77+
if ($LASTEXITCODE -eq 0) {
78+
Write-Host "✅ Successfully pulled ${image}" -ForegroundColor Green
79+
} else {
80+
Write-Host "❌ Failed to pull ${image}" -ForegroundColor Red
81+
exit 1
82+
}
83+
} catch {
84+
Write-Host "❌ Error pulling ${image}: $_" -ForegroundColor Red
85+
exit 1
86+
}
87+
}
88+
89+
Write-Host ""
90+
Write-Host "🎉 Initialization complete!" -ForegroundColor Green
91+
Write-Host "==========================" -ForegroundColor Green
92+
Write-Host "You can now run: docker compose up -d --build" -ForegroundColor Cyan
93+
Write-Host "This will start all services in development mode with hot-reload enabled." -ForegroundColor Cyan

scripts/init.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# Yuxi-Know Initialization Script for Bash/Linux/macOS
4+
# This script helps set up the environment for the Yuxi-Know project
5+
6+
set -e
7+
8+
echo "🚀 Initializing Yuxi-Know project..."
9+
echo "=================================="
10+
11+
# Check if .env file exists
12+
if [ -f ".env" ]; then
13+
echo "✅ .env file already exists. Skipping environment setup."
14+
else
15+
echo "📝 .env file not found. Let's set up your environment variables."
16+
echo ""
17+
18+
# Get SILICONFLOW_API_KEY
19+
echo "🔑 SiliconFlow API Key required"
20+
echo "Get your API key from: https://cloud.siliconflow.cn/i/Eo5yTHGJ"
21+
while true; do
22+
read -s -p "Please enter your SILICONFLOW_API_KEY: " SILICONFLOW_API_KEY
23+
echo ""
24+
if [ -z "$SILICONFLOW_API_KEY" ]; then
25+
echo "❌ API Key cannot be empty. Please try again."
26+
else
27+
break
28+
fi
29+
done
30+
31+
# Get TAVILY_API_KEY (optional)
32+
echo ""
33+
echo "🔍 Tavily API Key (optional) - for search service"
34+
echo "Get your API key from: https://app.tavily.com/"
35+
read -p "Please enter your TAVILY_API_KEY (press Enter to skip): " TAVILY_API_KEY
36+
37+
# Create .env file
38+
cat > .env << EOF
39+
# SiliconFlow API Key (required)
40+
SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY}
41+
42+
# Tavily API Key (optional - for search service)
43+
EOF
44+
45+
if [ -n "$TAVILY_API_KEY" ]; then
46+
echo "TAVILY_API_KEY=${TAVILY_API_KEY}" >> .env
47+
fi
48+
49+
echo "✅ .env file created successfully!"
50+
fi
51+
52+
echo ""
53+
echo "📦 Pulling Docker images..."
54+
echo "========================="
55+
56+
# List of Docker images to pull
57+
images=(
58+
"python:3.12-slim"
59+
"node:20-slim"
60+
"node:20-alpine"
61+
"milvusdb/milvus:v2.5.6"
62+
"neo4j:5.26"
63+
"minio/minio:RELEASE.2023-03-20T20-16-18Z"
64+
"ghcr.io/astral-sh/uv:0.7.2"
65+
"nginx:alpine"
66+
"quay.io/coreos/etcd:v3.5.5"
67+
)
68+
69+
# Pull each image
70+
for image in "${images[@]}"; do
71+
echo "🔄 Pulling ${image}..."
72+
if bash docker/pull_image.sh "$image"; then
73+
echo "✅ Successfully pulled ${image}"
74+
else
75+
echo "❌ Failed to pull ${image}"
76+
exit 1
77+
fi
78+
done
79+
80+
echo ""
81+
echo "🎉 Initialization complete!"
82+
echo "=========================="
83+
echo "You can now run: docker compose up -d --build"
84+
echo "This will start all services in development mode with hot-reload enabled."

0 commit comments

Comments
 (0)