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:
zhi
2026-03-06 13:15:54 +00:00
parent f34538e3b0
commit 6673372532
5 changed files with 94 additions and 1 deletions

View File

@@ -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