feat: integrate AbstractWizard for initialization
- Add wizard service (git.hangman-lab.top/hzhang/abstract-wizard:latest) - Add wizard-init service: uploads init-config on first deploy - Backend reads wizard config on startup, creates admin user + default project - Add init-config/harborforge.json with default admin credentials - Update README with initialization docs - Startup order: mysql → wizard → wizard-init → backend → frontend
This commit is contained in:
@@ -10,6 +10,10 @@ SECRET_KEY=change_me_in_production
|
||||
LOG_LEVEL=INFO
|
||||
BACKEND_PORT=8000
|
||||
|
||||
# AbstractWizard
|
||||
WIZARD_URL=http://wizard:8080
|
||||
WIZARD_CONFIG=harborforge.json
|
||||
|
||||
# Frontend
|
||||
FRONTEND_PORT=3000
|
||||
VITE_API_BASE=/api
|
||||
|
||||
Submodule HarborForge.Backend updated: 3cf2b1bc49...4b20444a5e
18
README.md
18
README.md
@@ -34,11 +34,29 @@ docker compose up -d
|
||||
宿主机 nginx (80/443)
|
||||
├── / → frontend (Docker, port 3000)
|
||||
└── /api/ → backend (Docker, port 8000)
|
||||
|
||||
Docker 内部:
|
||||
wizard (AbstractWizard) → 初始化配置管理
|
||||
wizard-init → 首次启动上传默认配置
|
||||
backend → 启动时从 wizard 读取配置,创建 admin 用户等
|
||||
```
|
||||
|
||||
前端 Docker 容器不包含 nginx,使用轻量的 `serve` 提供静态文件。
|
||||
API 代理由宿主机 nginx 统一处理。
|
||||
|
||||
### AbstractWizard 初始化
|
||||
|
||||
首次部署时,`wizard-init` 会将 `init-config/harborforge.json` 上传到 AbstractWizard。
|
||||
后端启动时自动从 AbstractWizard 读取配置并创建 admin 用户和默认项目。
|
||||
|
||||
修改初始化配置:
|
||||
```bash
|
||||
# 直接编辑 init-config/harborforge.json(首次部署前)
|
||||
# 或通过 AbstractWizard API 修改(部署后)
|
||||
curl -X PATCH http://localhost:18080/api/v1/config/harborforge.json \
|
||||
-d '{"admin": {"password": "new_secure_password"}}'
|
||||
```
|
||||
|
||||
### 宿主机 nginx 配置
|
||||
|
||||
参考 `nginx-host.conf.example`,复制到 `/etc/nginx/sites-available/` 并修改域名。
|
||||
|
||||
@@ -25,6 +25,59 @@ services:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
|
||||
# AbstractWizard — 初始化配置管理
|
||||
wizard:
|
||||
image: git.hangman-lab.top/hzhang/abstract-wizard:latest
|
||||
container_name: harborforge-wizard
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- wizard_config:/config
|
||||
- ./init-config:/init-config:ro
|
||||
environment:
|
||||
CONFIG_DIR: /config
|
||||
LISTEN_ADDR: "0.0.0.0:8080"
|
||||
MAX_BACKUPS: "5"
|
||||
# distroless image — no shell for healthcheck
|
||||
# wizard-init will retry until wizard is reachable
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.1'
|
||||
memory: 64M
|
||||
|
||||
# 初始化 — 将默认配置写入 AbstractWizard
|
||||
wizard-init:
|
||||
image: curlimages/curl:latest
|
||||
container_name: harborforge-wizard-init
|
||||
depends_on:
|
||||
- wizard
|
||||
volumes:
|
||||
- ./init-config:/init-config:ro
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
command:
|
||||
- |
|
||||
echo "Waiting for AbstractWizard to be ready..."
|
||||
for i in $$(seq 1 30); do
|
||||
if curl -sf http://wizard:8080/health > /dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
echo " attempt $$i/30..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "Checking if harborforge.json exists in wizard..."
|
||||
STATUS=$$(curl -s -o /dev/null -w '%%{http_code}' http://wizard:8080/api/v1/config/harborforge.json)
|
||||
if [ "$$STATUS" = "404" ]; then
|
||||
echo "Config not found, uploading init-config/harborforge.json..."
|
||||
curl -s -X PUT http://wizard:8080/api/v1/config/harborforge.json \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @/init-config/harborforge.json
|
||||
echo ""
|
||||
echo "Init config uploaded successfully."
|
||||
else
|
||||
echo "Config already exists (status=$$STATUS), skipping upload."
|
||||
fi
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./HarborForge.Backend
|
||||
@@ -35,11 +88,15 @@ services:
|
||||
DATABASE_URL: mysql+pymysql://${MYSQL_USER:-harborforge}:${MYSQL_PASSWORD:-harborforge_pass}@mysql:3306/${MYSQL_DATABASE:-harborforge}
|
||||
SECRET_KEY: ${SECRET_KEY:-change_me_in_production}
|
||||
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||
WIZARD_URL: http://wizard:8080
|
||||
WIZARD_CONFIG: harborforge.json
|
||||
ports:
|
||||
- "${BACKEND_PORT:-8000}:8000"
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
wizard-init:
|
||||
condition: service_completed_successfully
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
@@ -79,3 +136,5 @@ services:
|
||||
volumes:
|
||||
mysql_data:
|
||||
driver: local
|
||||
wizard_config:
|
||||
driver: local
|
||||
|
||||
12
init-config/harborforge.json
Normal file
12
init-config/harborforge.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"email": "admin@harborforge.local",
|
||||
"password": "changeme",
|
||||
"full_name": "HarborForge Admin"
|
||||
},
|
||||
"default_project": {
|
||||
"name": "Default",
|
||||
"description": "默认项目"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user