部署服务
按依赖顺序启动应用容器。此步骤之前中间件必须已运行——参见中间件部署。
部署顺序
按以下顺序部署(依赖关系自上而下):
1. app-prometheus ← core service, deploy first
2. support-email ← email sending
3. support-file ← file storage
4. support-schedule ← background tasks
5. partner-slash ← (optional) Slash integration
6. partner-stripe ← (optional) Stripe integration
7. support-tron-wallet ← (optional) TRON blockchain
8. support-solana-wallet ← (optional) Solana blockchain服务 5-8 为可选——按需部署即可。
1. app-prometheus(核心服务)
这是主要的 API 网关和业务逻辑服务。所有其他服务间接依赖于它。
bash
docker run -d \
--name slaunchx-app-prometheus-test \
--network slaunchx-intra \
-p 0.0.0.0:18020:18020 \
--env-file /opt/slaunchx/config/app-prometheus/test.env \
-e SPRING_PROFILES_ACTIVE=test \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/app-prometheus:dev-latest首次部署:数据库迁移
首次启动时,Flyway 会自动:
- 从基线迁移创建所有表
- 验证 schema 与预期状态一致
查看日志中的迁移进度:
bash
docker logs -f slaunchx-app-prometheus-test 2>&1 | grep -i flyway
# Expected: "Successfully applied X migrations"首次部署:初始化引导
如果这是全新环境,系统需要初始数据(机构、门户配置、管理员账户):
bash
docker run -d \
--name slaunchx-app-prometheus-test \
--network slaunchx-intra \
-p 0.0.0.0:18020:18020 \
--env-file /opt/slaunchx/config/app-prometheus/test.env \
-e SPRING_PROFILES_ACTIVE=test \
-e SYSTEM_BOOTSTRAP_CONFIG=/config/bootstrap.json \
-e SLAUNCHX_BOOTSTRAP_ADMIN_PASSWORD=initial-admin-password \
-v /opt/slaunchx/config/bootstrap.json:/config/bootstrap.json:ro \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/app-prometheus:dev-latestTIP
首次成功启动后,请移除引导变量。如果机构已存在,这些变量在后续启动时会被忽略。
验证
bash
curl -s http://localhost:18020/prometheus/actuator/health
# Expected: {"status":"UP"}2. support-email
bash
docker run -d \
--name slaunchx-support-email-test \
--network slaunchx-intra \
-p 0.0.0.0:18030:18030 \
--env-file /opt/slaunchx/config/support-email/test.env \
-e SPRING_PROFILES_ACTIVE=test \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/support-email:dev-latest验证:
bash
curl -s http://localhost:18030/email-service/actuator/health3. support-file
bash
docker run -d \
--name slaunchx-support-file-test \
--network slaunchx-intra \
-p 0.0.0.0:18040:18040 \
--env-file /opt/slaunchx/config/support-file/test.env \
-e SPRING_PROFILES_ACTIVE=test \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/support-file:dev-latest验证:
bash
curl -s http://localhost:18040/file-service/actuator/health4. support-schedule
bash
docker run -d \
--name slaunchx-support-schedule-test \
--network slaunchx-intra \
-p 0.0.0.0:18050:18050 \
--env-file /opt/slaunchx/config/support-schedule/test.env \
-e SPRING_PROFILES_ACTIVE=test \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/support-schedule:dev-latest验证:
bash
curl -s http://localhost:18050/schedule/actuator/health5. partner-slash(可选)
bash
docker run -d \
--name slaunchx-partner-slash-test \
--network slaunchx-intra \
-p 0.0.0.0:18101:18101 \
--env-file /opt/slaunchx/config/partner-slash/test.env \
-e SPRING_PROFILES_ACTIVE=test \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/partner-slash:dev-latest6. partner-stripe(可选)
bash
docker run -d \
--name slaunchx-partner-stripe-test \
--network slaunchx-intra \
-p 0.0.0.0:18102:18102 \
--env-file /opt/slaunchx/config/partner-stripe/test.env \
-e SPRING_PROFILES_ACTIVE=test \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/partner-stripe:dev-latest7. support-tron-wallet(可选)
bash
docker run -d \
--name slaunchx-support-tron-wallet-test \
--network slaunchx-intra \
-p 0.0.0.0:18060:18060 \
--env-file /opt/slaunchx/config/support-tron-wallet/test.env \
-e SPRING_PROFILES_ACTIVE=test \
-v tron-wallet-test-data:/data \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/support-tron-wallet:dev-latest数据卷挂载
钱包服务在本地存储密钥材料。-v 卷挂载至关重要——丢失此卷意味着丢失钱包密钥。
8. support-solana-wallet(可选)
bash
docker run -d \
--name slaunchx-support-solana-wallet-test \
--network slaunchx-intra \
-p 0.0.0.0:18070:18070 \
--env-file /opt/slaunchx/config/support-solana-wallet/test.env \
-e SPRING_PROFILES_ACTIVE=test \
-v solana-wallet-test-data:/data \
--log-opt max-size=50m --log-opt max-file=3 \
--restart unless-stopped \
localhost:5000/slaunchx/support-solana-wallet:dev-latest使用部署脚本
为方便起见,仓库中包含一个部署脚本,可以处理 stop/rm/pull/run:
bash
# Deploy all modules to test
ci/local/deploy.sh test
# Deploy single module
ci/local/deploy.sh test app-prometheus
# Deploy with a specific image tag
ci/local/deploy.sh test app-prometheus --tag dev-20260314-091500
# Preview commands without executing
ci/local/deploy.sh test --dry-run容器命名规范
slaunchx-{module}-{environment}示例:
slaunchx-app-prometheus-testslaunchx-support-email-alphaslaunchx-mysql-test
部署检查清单
- [ ] 所有中间件容器运行中且已验证
- [ ] app-prometheus 已启动且健康检查返回 UP
- [ ] Flyway 迁移已成功完成(首次部署)
- [ ] 初始化引导数据已创建(首次部署)
- [ ] 所有所需的可选服务已启动
- [ ] 所有容器使用
--restart unless-stopped - [ ] 日志轮转已配置(
max-size=50m、max-file=3)