feat: add java control plane container baseline
This commit is contained in:
1 parent
2897354dd8
commit
1615401185
18 files changed
+566
No files matched your search
@@ -0,0 +1,31 @@
|
||||
# Copy to .env on the target server. Do not commit the real file.
|
||||
MOYI_HTTP_PORT=8080
|
||||
|
||||
POSTGRES_USER=moyi
|
||||
POSTGRES_PASSWORD=replace-with-a-long-random-password
|
||||
POSTGRES_DB=moyi_control
|
||||
|
||||
REDIS_PASSWORD=replace-with-a-long-random-password
|
||||
|
||||
SESSION_TTL_HOURS=168
|
||||
AUTH_PASSWORD_PEPPER=replace-with-a-long-random-secret-at-least-32-chars
|
||||
ADMIN_ACCOUNT=adimin
|
||||
ADMIN_PASSWORD=replace-with-a-strong-initial-password
|
||||
ADMIN_DISPLAY_NAME=平台管理员
|
||||
|
||||
# Optional upstream gateway endpoint used after Otari/adapter integration.
|
||||
OTARI_BASE_URL=http://otari:8000
|
||||
|
||||
# Object storage: external Alibaba Cloud OSS or an S3-compatible service.
|
||||
OSS_ENDPOINT=
|
||||
OSS_REGION=
|
||||
OSS_BUCKET=
|
||||
OSS_ACCESS_KEY_ID=
|
||||
OSS_ACCESS_KEY_SECRET=
|
||||
|
||||
# Provider credentials: only injected into the API container.
|
||||
TRIPO_API_KEY=
|
||||
DEEPSEEK_API_KEY=
|
||||
KIMI_API_KEY=
|
||||
ZHIPU_API_KEY=
|
||||
VOLCENGINE_API_KEY=
|
||||
@@ -0,0 +1,41 @@
|
||||
# MOYI 容器化部署基线
|
||||
|
||||
这套 Compose 用于 MOYI 的 Java 后端迁移基线:Vue 前端以 Nginx 生产构建运行,Java Control Plane 以 Spring Boot 运行,PostgreSQL 和 Redis 使用独立持久化卷。OSS 不在 Compose 中自建,生产环境连接云厂商 OSS;本地如需模拟对象存储,可另行增加 MinIO profile。
|
||||
|
||||
## 当前迁移状态
|
||||
|
||||
`control-plane-java/` 当前提供 Java 21 / Spring Boot 的启动和健康检查骨架。现有 TypeScript Control Plane 仍是接口迁移期间的可用实现,Java 服务完成认证、模型目录、Key、路由和任务接口迁移并通过 UAT 前,不要直接把生产流量切到 Java 服务。
|
||||
|
||||
## 启动
|
||||
|
||||
```powershell
|
||||
cd infra/moyi
|
||||
Copy-Item .env.example .env
|
||||
```
|
||||
|
||||
编辑 `.env` 中的数据库、Redis、管理员和密钥变量,然后执行:
|
||||
|
||||
```powershell
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
docker compose ps
|
||||
Invoke-WebRequest http://localhost:8080/health
|
||||
```
|
||||
|
||||
前端入口为 `http://localhost:8080`。当前 Java 骨架阶段只保证 `/health` 可用;业务接口仍需完成迁移后才适合用此 Compose 做完整用户验收。
|
||||
|
||||
## 停止与数据
|
||||
|
||||
```powershell
|
||||
docker compose down
|
||||
```
|
||||
|
||||
不要在没有备份的情况下使用 `docker compose down -v`,它会删除 PostgreSQL 和 Redis 的本地卷。
|
||||
|
||||
## 生产注意事项
|
||||
|
||||
- 生产环境把 `MOYI_HTTP_PORT` 放在反向代理之后,只暴露 HTTPS 入口,不直接公网暴露 PostgreSQL 和 Redis。
|
||||
- `POSTGRES_PASSWORD`、`REDIS_PASSWORD`、`AUTH_PASSWORD_PEPPER`、管理员密码、供应商 Key 和 OSS Secret 不提交 Git,也不要写入前端构建参数。
|
||||
- OSS AccessKey 只授予目标 Bucket 的最小权限,应用使用临时凭证或 RAM 子账号优先。
|
||||
- 正式上线前固定基础镜像 digest,执行漏洞扫描、依赖许可证审计、数据库备份恢复演练和回滚演练。
|
||||
- Java 服务完成业务迁移后,再把数据库迁移、Redis 队列、OSS 对象元数据和监控告警纳入发布流水线。
|
||||
@@ -0,0 +1,73 @@
|
||||
name: moyi
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-moyi}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in infra/moyi/.env}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-moyi_control}
|
||||
volumes:
|
||||
- moyi_postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
restart: unless-stopped
|
||||
command: ["redis-server", "--appendonly", "yes", "--requirepass", "${REDIS_PASSWORD:?Set REDIS_PASSWORD in infra/moyi/.env}"]
|
||||
volumes:
|
||||
- moyi_redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "-a", "$${REDIS_PASSWORD}", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
|
||||
moyi-api:
|
||||
build:
|
||||
context: ../../control-plane-java
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- path: .env
|
||||
required: false
|
||||
environment:
|
||||
CONTROL_PLANE_HOST: 0.0.0.0
|
||||
CONTROL_PLANE_PORT: 8787
|
||||
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/${POSTGRES_DB:-moyi_control}
|
||||
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER:-moyi}
|
||||
SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
SPRING_DATA_REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379/0
|
||||
FLYWAY_ENABLED: true
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O - http://127.0.0.1:8787/health | grep -q 'status'"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
start_period: 20s
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ../../prototype
|
||||
args:
|
||||
VITE_CONTROL_PLANE_URL: /
|
||||
VITE_AUTH_MODE: remote
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${MOYI_HTTP_PORT:-8080}:80"
|
||||
depends_on:
|
||||
moyi-api:
|
||||
condition: service_healthy
|
||||
|
||||
volumes:
|
||||
moyi_postgres_data:
|
||||
moyi_redis_data:
|
||||
Reference in new issue
Block a user