From 262c8eec7fd3436930501c9a250ca2fa32a41dc8 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 15 Jun 2023 16:49:32 +0800 Subject: [PATCH] docs: add manual deploy document --- website/docs/deployment/manual.md | 87 +++++++++++++++++++ .../current/deployment/manual.md | 87 +++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 website/docs/deployment/manual.md create mode 100644 website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/manual.md diff --git a/website/docs/deployment/manual.md b/website/docs/deployment/manual.md new file mode 100644 index 00000000..9b8f900c --- /dev/null +++ b/website/docs/deployment/manual.md @@ -0,0 +1,87 @@ +--- +sidebar_position: 6 +title: Manual Deployment +--- + +:::caution +The content of this chapter requires you to have a certain degree of understanding of nodejs, git, linux. When there are problems such as dependency problems, environmental problems, system problems, etc., you need to have the ability to solve and troubleshoot problems by yourself. + +If you do not understand this, it is not recommended that you use the contents of this chapter for deployment. It is recommended to use a unified image for deployment. +::: + +## Dependencies + +- git +- nodejs v16.18.0 or above +- pnpm v8.3.1 or above +- mongodb +- redis +- minio + +## Download the source code + +```bash +mkdir msgbyte && cd msgbyte + +git clone https://github.com/msgbyte/tailchat.git +``` + +### Switch to stable code + +Because the cloned code is the latest code, it may be unstable for a short period of time, so if you want to switch to the stable code of each version, you can use the tag function of git + +For example, if you wanna use `v1.7.6`, you can use the command: + +```bash +git checkout v1.7.6 +``` + +## Compile the project + +Tailchat is a front-end and back-end separated project. So we have to deal with the front-end code and the back-end code separately + +### Install dependencies + +We assume you have installed `nodejs v16.18.0+` or above. And installed `pnpm v8.3.1` or above + +```bash +cd tailchat +pnpm install +``` + +This command will take some time to install all the dependencies of Tailchat. When the installation is complete, the internal plug-in will automatically execute the compilation command. + +### Building the project + +```bash +NODE_ENV=production pnpm build +``` + +This command will execute the commands for compiling the front-end and back-end management terminals in parallel. And move the front-end product to the `server/dist/public` directory of the server + +When the project is built, our product can run normally + +:::caution +Please build in `macos` / `linux` environment as much as possible, window does not necessarily fully support shell commands +::: + +## Run the project + +In order to ensure the horizontal expansion of the project, although the core code of `Tailchat` is written in the same project, it can be divided into multiple subdivided microservices when it is actually started. Selectively enable different services by passing in a combination of different environment variables. + +Create an environment variable file in the server directory using the `.env.example` directory as an example + +```bash +cp server/.env.example server/dist/.env +vim .env +``` + +Modify the necessary environment variables to your own, such as `MONGO_URL`, `REDIS_URL`, `MINIO_URL` + +then start the service + +```bash +SERVICEDIR=services,plugins pnpm start:service +``` + +> `SERVICEDIR` indicates the directory where the microservice is loaded diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/manual.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/manual.md new file mode 100644 index 00000000..67e6c961 --- /dev/null +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/manual.md @@ -0,0 +1,87 @@ +--- +sidebar_position: 6 +title: 手动部署 +--- + +:::caution +本章内容需要你对 nodejs, git, linux 有一定程度的了解。当出现如依赖问题、环境问题、系统问题等问题时需要具备自行解决和排查问题的能力。 + +如果你对此并不了解,不建议你使用本章内容进行部署。建议使用统一镜像进行部署。 +::: + +## 依赖 + +- git +- nodejs v16.18.0 或以上 +- pnpm v8.3.1 或以上 +- mongodb +- redis +- minio + +## 下载源码 + +```bash +mkdir msgbyte && cd msgbyte + +git clone https://github.com/msgbyte/tailchat.git +``` + +### 切换到稳定代码 + +因为克隆下来的代码是最新代码,可能存在短时间内不稳定的情况,因此如果想要切换到各个版本的稳定代码的话可以使用git的tag功能 + +如切换到`v1.7.6`则可以使用命令: + +```bash +git checkout v1.7.6 +``` + +## 编译项目 + +Tailchat 是一个前后端分离的项目。因此我们要分别处理前端代码和后端代码 + +### 安装依赖 + +我们假设你已经安装了 `nodejs v16.18.0+` 或者以上的版本。以及安装了 `pnpm v8.3.1` 或以上版本 + +```bash +cd tailchat +pnpm install +``` + +该命令会花费一些时间,将Tailchat所有的依赖都安装一遍。当安装完毕后内部的插件会自动执行编译命令。 + +### 构建项目 + +```bash +NODE_ENV=production pnpm build +``` + +该命令会并行执行编译前端后端管理端的命令。并将前端产物移动到服务端的 `server/dist/public` 目录 + +当项目构建完毕后我们的产物就可以正常运行了 + +:::caution +请尽可能在 `macos` / `linux` 环境进行构建,window 对 shell 命令支持并不一定完全 +::: + +## 运行项目 + +为了确保项目能够水平扩容,`Tailchat` 的核心代码虽然写在同一个项目中,但是实际启动起来的时候可以被划分为多个细分的微服务。通过传入不同的环境变量的组合来实现有选择的启用不同的服务。 + +在server目录下以`.env.example`目录为例创建一个环境变量文件 + +```bash +cp server/.env.example server/dist/.env +vim .env +``` + +将必要的环境变量修改为自己的,如 `MONGO_URL`, `REDIS_URL`, `MINIO_URL` + +然后启动服务 + +```bash +SERVICEDIR=services,plugins pnpm start:service +``` + +> `SERVICEDIR` 表示加载微服务的目录