AstroResearch/docs/deployment.md

47 lines
1.6 KiB
Markdown
Raw 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.

# AstroResearch Deployment Guide / 部署指南
AstroResearch 的后端服务是由 Rust 编译出的单执行文件,它内置托管了前端 React 的静态构建资源,因此生产部署十分简单。
---
## 1. 系统要求与环境依赖 (Requirements)
- **操作系统**Linux / macOS / Windows
- **运行环境**
- Node.js (v18+) 用以构建前端 React 资源
- Rust (1.75+) 用以编译后端 Axum 进程
- SQLite (自动内置,无需单独部署)
---
## 2. 生产构建步骤 (Production Build Steps)
### 步骤 1构建 React 前端静态资源
进入 `dashboard` 文件夹,安装依赖并执行编译命令。编译产物会自动输出在 `dashboard/dist` 目录下:
```bash
cd dashboard
npm install
npm run build
```
### 步骤 2编译 Rust 后端二进制文件
返回项目根目录,通过 Cargo 构建 Release 版本的执行文件。编译后的程序会内置链接 `dashboard/dist` 下的全部静态资源:
```bash
cd ..
cargo build --release
```
编译产物位于 `target/release/astroresearch`
---
## 3. 服务部署与启动 (Running in Production)
1. 将编译出来的 `target/release/astroresearch` 二进制文件部署到目标服务器。
2. 在二进制文件同一目录下,创建并填写 `.env` 环境变量配置文件(可从根目录的 `.env.example` 复制模板)。
3. 确保本地相对路径下拥有天文对照词典文件 `dictionary.txt`
4. 运行后端服务:
```bash
./astroresearch
```
5. 进程将默认在后台启动并监听 `http://localhost:8000` 端口。你可以通过 Nginx 将此端口反向代理到公网 80/443 端口。