Files
HAOVP/docs/开发环境搭建.md
Toys-A 30c17f01e9 docs: Refresh deployment and API documentation
- Align deployment guidance with the current three-node Compose topology
- Document the current frontend architecture and development workflow
- Replace the stale API list with a controller-based route index
2026-08-18 23:37:49 +08:00

76 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 开发环境搭建
本文档对应当前仓库结构。后端配置通过 Nacos 导入,开发环境默认使用 `dev` profile;不要再按旧文档分别启动带固定密码的 MySQL、Redis、MinIO 容器。
## 环境要求
- JDK 17
- Maven 3.9+(或使用 IDE 的 Maven)
- Node.js 18+
- Docker Engine 与 Docker Compose v2
## 启动基础设施
在仓库根目录执行:
```bash
cd backend
cp .env.example .env
docker compose up -d mysql redis redis-sentinel nacos rmqnamesrv rmqbroker minio sentinel
```
`docker-compose.yml` 会初始化业务数据库和 Nacos schema;Nacos 配置由 `sql/nacos-config-init.sql` 导入。首次启动后确认 Nacos 健康,再启动业务服务。
常用基础设施端口:
| 组件 | 端口 |
| --- | --- |
| MySQL | 3306 |
| Redis / Sentinel | 6379 / 26379 |
| Nacos(HTTP/gRPC) | 8848 / 9848 / 9849 |
| RocketMQ NameServer / Broker | 9876 / 10911 |
| MinIO API / Console | 9100 / 9101 |
| Sentinel Dashboard | 8880 |
## 启动后端
后端模块端口固定为:网关 `9000`、认证 `9001`、用户 `9002`、内容 `9003`、评论 `9004`、推荐 `9005`、管理 `9006`。推荐使用 Docker Compose 一次启动:
```bash
cd backend
docker compose up -d --build video-gateway video-auth video-user video-content video-comment video-recommend video-admin
```
本地 IDE 启动时,先启动 Nacos 及依赖,并将 `SPRING_PROFILES_ACTIVE=dev`;各模块的 `application.yml` 会从 Nacos 加载 `common.yaml`、`common-redis-dev.yaml` 和对应服务配置。
## 启动前端
```bash
cd frontend/video-frontend-web
npm install
npm run dev
cd ../video-frontend-admin
npm install
npm run dev
```
用户端默认端口 `3000`,管理端默认端口 `3100`。Vite 将 `/api` 代理到 `VITE_PROXY_TARGET`,未设置时为 `http://192.168.1.101:9000`;本地开发可在对应前端目录的 `.env.local` 设置为 `http://127.0.0.1:9000`。
## 构建与测试
```bash
cd backend
mvn test
mvn package -DskipTests
cd ../frontend/video-frontend-web
npm run build
cd ../video-frontend-admin
npm run build
```
## 配置安全
`.env`、Nacos 密码、JWT secret、MinIO 密钥和初始化管理员密码只应通过环境变量提供。文档中的地址均为示例,不要提交真实凭据。