Skip to content

Commit 2fa4942

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 268e63d commit 2fa4942

49 files changed

Lines changed: 2503 additions & 370 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/QUICK_START.md

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# 🚀 DevContainer 快速開始
2+
3+
## 立即重建(3 步驟)
4+
5+
### ⚡ 步驟 1: 打開 VS Code Command Palette
6+
7+
**Windows/Linux:**
8+
```
9+
Ctrl + Shift + P
10+
```
11+
12+
**macOS:**
13+
```
14+
Cmd + Shift + P
15+
```
16+
17+
### ⚡ 步驟 2: 執行重建命令
18+
19+
輸入並選擇:
20+
```
21+
Dev Containers: Rebuild Container Without Cache
22+
```
23+
24+
或簡短版本:
25+
```
26+
>rebuild
27+
```
28+
(自動補全會顯示完整命令)
29+
30+
### ⚡ 步驟 3: 等待完成
31+
32+
**預計時間:**
33+
- 首次構建:2-4 分鐘
34+
- 後續重建:30-60 秒
35+
36+
**進度指示:**
37+
```
38+
[1/5] Pulling base image... ⏳ 30s
39+
[2/5] Installing features... ⏳ 90s
40+
[3/5] Installing tools... ⏳ 90s
41+
[4/5] Running bootstrap... ⏳ 30s
42+
[5/5] Starting container... ⏳ 10s
43+
```
44+
45+
---
46+
47+
## ✅ 驗證安裝
48+
49+
重建完成後,在終端執行:
50+
51+
```bash
52+
# 快速驗證(30 秒)
53+
bash .devcontainer/scripts/verify-devcontainer.sh
54+
```
55+
56+
**預期輸出:**
57+
```
58+
🔍 DevContainer Verification Test Suite
59+
========================================
60+
✅ Passed: 45
61+
❌ Failed: 0
62+
⏭️ Skipped: 3
63+
📊 Total: 48
64+
📈 Success Rate: 100%
65+
✅ All tests passed!
66+
```
67+
68+
---
69+
70+
## 🎯 立即可用的功能
71+
72+
### 語言環境
73+
- ✅ Go 1.24.7
74+
- ✅ Python 3.11
75+
- ✅ Node.js 20
76+
77+
### Kubernetes 工具
78+
- ✅ kubectl 1.31.0
79+
- ✅ helm 3.16.2
80+
- ✅ kind 0.23.0
81+
82+
### 開發工具
83+
- ✅ golangci-lint
84+
- ✅ gosec
85+
- ✅ kubebuilder
86+
- ✅ pre-commit
87+
88+
### 容器工具
89+
- ✅ Docker (via host)
90+
- ✅ docker-compose
91+
92+
---
93+
94+
## 🚀 快速測試
95+
96+
### 測試 1: 創建 Kind 集群(1 分鐘)
97+
```bash
98+
kind create cluster --name test-cluster
99+
kubectl cluster-info
100+
kind delete cluster --name test-cluster
101+
```
102+
103+
### 測試 2: Go 構建(30 秒)
104+
```bash
105+
cd orchestrator
106+
go build -v ./...
107+
```
108+
109+
### 測試 3: Docker 構建(30 秒)
110+
```bash
111+
docker build -t test:latest -f - . <<EOF
112+
FROM alpine:latest
113+
RUN echo "Success"
114+
EOF
115+
```
116+
117+
---
118+
119+
## 📊 性能提升驗證
120+
121+
### 驗證緩存加速
122+
123+
**首次 Go 構建:**
124+
```bash
125+
time go build ./...
126+
# 預期: ~1-2 分鐘
127+
```
128+
129+
**第二次 Go 構建(使用緩存):**
130+
```bash
131+
time go build ./...
132+
# 預期: ~5-10 秒
133+
```
134+
135+
**性能提升:** 90%+ ⚡
136+
137+
---
138+
139+
## 🔒 安全驗證
140+
141+
```bash
142+
# 檢查不是特權模式
143+
docker inspect $(hostname) | grep '"Privileged": false'
144+
# 預期: "Privileged": false
145+
146+
# 運行完整安全掃描
147+
bash .devcontainer/scripts/devcontainer-security-check.sh
148+
# 預期: ✅ Security checks completed successfully!
149+
```
150+
151+
---
152+
153+
## 📝 常用命令
154+
155+
### 開發命令
156+
```bash
157+
make help # 查看所有命令
158+
make verify-env # 驗證環境
159+
make test # 運行測試
160+
make kind # 創建 Kind 集群
161+
```
162+
163+
### DevContainer 命令
164+
```bash
165+
# 重建容器
166+
Ctrl+Shift+P → "Rebuild Container"
167+
168+
# 重新打開
169+
Ctrl+Shift+P → "Reopen in Container"
170+
171+
# 查看日誌
172+
Ctrl+Shift+P → "Show Container Log"
173+
```
174+
175+
---
176+
177+
## ❌ 遇到問題?
178+
179+
### 快速修復
180+
181+
**問題:構建失敗**
182+
```bash
183+
# 清理並重建
184+
docker system prune -f
185+
# VS Code: Rebuild Container Without Cache
186+
```
187+
188+
**問題:權限錯誤**
189+
```bash
190+
sudo chown -R vscode:vscode /workspace
191+
```
192+
193+
**問題:Git 錯誤**
194+
```bash
195+
git config --global --add safe.directory /workspace
196+
```
197+
198+
### 詳細診斷
199+
```bash
200+
# 運行完整驗證
201+
bash .devcontainer/scripts/verify-devcontainer.sh
202+
203+
# 查看環境信息
204+
make info
205+
```
206+
207+
---
208+
209+
## 📚 詳細文檔
210+
211+
- **完整重建指南**: `.devcontainer/REBUILD_GUIDE.md`
212+
- **變更日誌**: `docs/DEVCONTAINER_CHANGELOG.md`
213+
- **安全評估**: `docs/DEVCONTAINER_SECURITY.md`
214+
215+
---
216+
217+
## 🎉 完成!
218+
219+
環境已準備就緒。開始開發:
220+
221+
```bash
222+
# 創建開發集群
223+
make kind
224+
225+
# 運行測試
226+
make test
227+
228+
# 構建組件
229+
make build
230+
231+
# 快樂編碼! 🚀
232+
```

0 commit comments

Comments
 (0)