docs: 更新部署文档
This commit is contained in:
parent
1f7b232730
commit
359262891c
@ -1,26 +1,26 @@
|
||||
---
|
||||
title: 部署(待更新)
|
||||
title: 部署
|
||||
createTime: 2025/03/29 23:50:17
|
||||
permalink: /guide/n6o11owv/
|
||||
---
|
||||
|
||||
> **此文档尚未更新,请勿参考。**
|
||||
|
||||
> 本文档适用于部署 Astral3D 编辑器到服务器上。 <br />
|
||||
> 以[Golang版本](https://github.com/mlt131220/Astral3DEditorGoBack)后端为例,其他语言版本后端部署方式请参考官方文档。
|
||||
> 以[Java版本](https://github.com/yx8663/astral-service)后端为例,其他语言版本后端部署方式请参考官方文档。
|
||||
|
||||
## 本地打包
|
||||
|
||||
### 前端打包
|
||||
```bash
|
||||
# 确认 Node.js 版本(≥ 23.x)
|
||||
# 确认 Node.js 版本(≥ 23.11.x)
|
||||
node -v
|
||||
|
||||
# 拉取代码
|
||||
git clone https://github.com/mlt131220/Astral3D.git
|
||||
|
||||
# 安装依赖
|
||||
# 进入项目
|
||||
cd Astral3D
|
||||
|
||||
# 安装依赖
|
||||
pnpm install
|
||||
|
||||
# 打包 Astral 3D Engine SDK
|
||||
@ -32,32 +32,33 @@ pnpm run editor:build
|
||||
|
||||
### 后端打包
|
||||
```bash
|
||||
# 确认go环境
|
||||
go version
|
||||
# 确认java环境
|
||||
java -version
|
||||
|
||||
# 确认maven环境
|
||||
mvn -v
|
||||
|
||||
# 拉取代码
|
||||
git clone https://github.com/mlt131220/Astral3DEditorGoBack.git
|
||||
git clone https://github.com/yx8663/astral-service
|
||||
|
||||
# 安装依赖
|
||||
go mod tidy
|
||||
mvn clean install
|
||||
|
||||
# 修改数据库等配置(修改 conf/app.conf,详见 https://github.com/mlt131220/Astral3DEditorGoBack/blob/main/README.md)
|
||||
edit conf/app.conf
|
||||
# 修改数据库等配置(修改 astral-web/src/main/resources/application-dev.yml,详见 https://github.com/yx8663/astral-service/blob/develop/README.md#%E9%85%8D%E7%BD%AE)
|
||||
vim astral-web/src/main/resources/application-dev.yml
|
||||
|
||||
# 安装bee工具
|
||||
go get -u github.com/beego/bee/v2
|
||||
# 编译打包(通过maven打包即可跨平台)
|
||||
# 生产环境推荐用clean package跳过测试
|
||||
mvn clean package -DskipTests
|
||||
|
||||
# 编译后端代码
|
||||
# Linux
|
||||
bee pack -be GOOS=linux -be GOARCH=amd64
|
||||
# Windows
|
||||
bee pack -be GOOS=windows
|
||||
# jar包: astral-web/target/astral-web.jar
|
||||
ls -l astral-web/target/*.jar
|
||||
```
|
||||
|
||||
## 服务器部署(Windows)
|
||||
|
||||
### 基础环境
|
||||
- [Nginx](https://nginx.org/en/download.html)
|
||||
- [Nginx](https://nginx.org/en/download.html)/[caddy](https://caddyserver.com/)
|
||||
- [MySQL](https://www.mysql.com/cn/downloads/)
|
||||
|
||||
或者直接使用集成环境,如[PHPStudy](https://old.xp.cn/download.html)。
|
||||
@ -66,10 +67,23 @@ bee pack -be GOOS=windows
|
||||
将Astral 3D Editor打包后的文件放到方便读取的目录下,如 `C:\www\Astral3dEditor`;
|
||||
|
||||
### 后端部署
|
||||
1. 将后端编译后的文件放到方便读取的目录下,如 `C:\www\Astral3DEditorGoBack`;
|
||||
2. 打开 MySQL 数据库,创建名为 `astral3d` 的数据库,并导入 `Astral3DEditorGoBack/static/sql/astral-3d-editor.sql` 文件;
|
||||
3. 启动 MySQL 服务,并确保 MySQL 服务正常运行;
|
||||
4. 双击后端程序打包生成的可执行文件 `Astral3DEditorGoBack.exe` 启动后端服务,默认监听 `8080` 端口;
|
||||
1. 将后端部署所需文件/文件夹放到方便读取的目录下,如 `C:\www\Astral3DEditorBack`,所需文件/文件夹如下:
|
||||
* `static` 文件夹;
|
||||
* `astral-web/target/astral-web.jar`;
|
||||
* `astral-web/src/main/resources/application.yml`
|
||||
* `astral-web/src/main/resources/application-dev.yml`
|
||||
2. 此时`C:\www\Astral3DEditorBack`内容如下:
|
||||
|
||||
``` shell
|
||||
- static/
|
||||
- application.yml
|
||||
- application-dev.yml
|
||||
- astral-web.jar
|
||||
```
|
||||
|
||||
3. 打开 MySQL 数据库,创建配置在 `application-dev.yml` 的数据库,并导入 `static/sql/astral_3d.sql` 文件;
|
||||
4. 启动 MySQL 服务,并确保 MySQL 服务正常运行;
|
||||
5. 在 `C:\www\Astral3DEditorBack` 下运行命令 `java -jar astral-web.jar` 启动后端服务,默认监听 `8080` 端口;
|
||||
|
||||
### Nginx 配置
|
||||
1. 打开 Nginx 配置文件,假设nginx安装目录为`C:\nginx`,则配置文件路径为`C:\nginx\conf\nginx.conf`;
|
||||
@ -102,6 +116,11 @@ bee pack -be GOOS=windows
|
||||
try_files $uri $uri/ index.html;
|
||||
# 项目入口文件
|
||||
index index.html;
|
||||
|
||||
# 协商缓存配置,30天
|
||||
add_header Cache-Control "public, max-age=2592000";
|
||||
expires 30d;
|
||||
etag on;
|
||||
}
|
||||
|
||||
# 后端api接口代理,接口请求匹配 /api 的会走此处转发,下面都同理
|
||||
@ -122,20 +141,14 @@ bee pack -be GOOS=windows
|
||||
proxy_send_timeout 300s;
|
||||
}
|
||||
|
||||
# 如果需要使用upyun上传功能,则需要添加以下配置
|
||||
# 假设 http://upyun.xxx.com 为你的upyun存储
|
||||
|
||||
location /upyun {
|
||||
rewrite ^/upyun(.*)$ $1 break;
|
||||
proxy_pass http://upyun.xxx.com;
|
||||
}
|
||||
|
||||
location /static/upload {
|
||||
proxy_pass http://upyun.xxx.com/static/upload;
|
||||
}
|
||||
|
||||
location /static/bim2gltf {
|
||||
proxy_pass http://upyun.xxx.com/static/bim2gltf;
|
||||
location /file/static {
|
||||
log_not_found off;
|
||||
# 关闭日志
|
||||
access_log off;
|
||||
# 强缓存设置,缓存时间设置为0.5年
|
||||
add_header Cache-Control "public, max-age=15768000";
|
||||
|
||||
proxy_pass http://localhost:8080/api/common/static;
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -155,12 +168,3 @@ nginx -s reload
|
||||
|
||||
## Docker 部署
|
||||
|
||||
|
||||
## 注意事项
|
||||
1. 后端打包前请确认`Astral3DEditorGoBack/conf/app.conf`文件中的`runmode = prod`;
|
||||
2. 后端部署时,请确保 MySQL 数据库配置正确,并导入 `Astral3DEditorGoBack/static/sql/astral-3d-editor.sql` 文件;
|
||||
3. 前端部署时,请确保 Nginx 配置正确,并将前端部署到服务器上;
|
||||
4. 后端部署时,请确保后端程序启动成功,并监听 `Astral3DEditorGoBack/conf/app.conf`中配置的端口`httpport `,默认为 `8080` ;
|
||||
5. 前端部署时,请确保前端程序启动成功,并监听 Nginx 配置中配置的端口,比如上面示例的 `80` 端口;
|
||||
6. 部署完成后,请确保 Nginx 与 MySQL 服务正常运行;
|
||||
7. 部署完成后,请确保前端程序与后端程序正常运行;
|
||||
Loading…
Reference in New Issue
Block a user