This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
{
"label": "Application Deployment",
"position": 10
}

View File

@@ -0,0 +1,42 @@
---
sidebar_position: 9
title: Deployment admin platform (optional)
---
:::info
The feature of `admin` is still being iterated, and it is currently in the early trial version
We will continue to enrich the internal content in the future
:::
Get the latest `admin` configuration from `github`:
```bash
wget https://raw.githubusercontent.com/msgbyte/tailchat/master/docker/admin.yml
```
Set the account and password of the `admin` in the environment variable `docker-compose.env`:
```ini
ADMIN_USER=tailchat
ADMIN_PASS=<Write the independent background password here, do not tell others>
```
Then use [Multiple Files](https://docs.docker.com/compose/extends/#understanding-multiple-compose-files) to start the application:
```bash
docker compose -f docker-compose.yml -f admin.yml up -d
```
*Pay attention to the order, because `admin.yml` depends on `docker-compose.yml`, so it should be placed behind*
At this time, add `/admin/` after the access backend address to access:
```
https://tailchat.example.com/admin/
```
*Note: don't forget to have a `/` at the end*
<details>
<summary>About the deprecated legacy admin</summary>
admin-old will be remove in v1.8.6. you can checkout version before to get it
</details>

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

View File

@@ -0,0 +1,34 @@
---
sidebar_position: 11
title: CDN Deployment (optional)
---
There may be cases where front-end and back-end are deployed separately. For example, if you want to manage front-end code separately in object storage, add CDN support. You need to compile the front-end code separately.
Backend code is still recommended to use `docker` to deploy
In order to compile the front-end code separately, you need to download the source code and compile it manually
```bash
git clone https://github.com/msgbyte/tailchat.git
cd tailchat
# You can switch between different distributions by git, for example: git checkout v1.8.8
pnpm install # You need to use `pnpm` to install dependencies, using other package management tools may cause problems. and you should use pnpm@8 because here is some break change in pnpm@9
```
Wait patiently for dependencies to be installed
Enter the front-end code and compile it
```bash
cd client/web
SERVICE_URL=<your-api-url> pnpm build
```
Make sure the value of `SERVICE_URL` is the address of your api backend, for example: `http://127.0.0.1:11000`
After compiling, you can get all the front-end files in the `tailchat/client/web/dist` directory.
> In addition, if there is a 404 report after refreshing the page, you need to configure a configuration similar to [When hosting a static website, set the index.html file in the root directory as the default home page]

View File

@@ -0,0 +1,85 @@
---
sidebar_position: 99
title: Development environment
---
For setting up the development environment, tailchat provides a very simple and fast way:
## Use Docker to quickly build a dependent environment
**mongodb**
```bash
docker run -d --name mongo -p 27017:27017 mongo:4
```
**redis**
```bash
docker run -d --name redis -p 6379:6379 redis
```
**minio**
```bash
docker run -d \
-p 19000:9000 \
-p 19001:9001 \
--name minio \
-e "MINIO_ROOT_USER=tailchat" \
-e "MINIO_ROOT_PASSWORD=com.msgbyte.tailchat" \
minio/minio server /data --console-address ":9001"
```
### Example
Here is a minimal example `.env` which let you can run tailchat in development environment.
```ini
PORT=11000
MONGO_URL=mongodb://127.0.0.1:27017/tailchat
REDIS_URL=redis://localhost:6379/
MINIO_URL=127.0.0.1:19000
MINIO_USER=tailchat
MINIO_PASS=com.msgbyte.tailchat
```
## Node Version
Tailchat is develop with `nodejs`, please install nodejs by yourself, here is nodejs official: [https://nodejs.org/](https://nodejs.org/)
Suggestion to use `nodejs18.x`, and not support `nodejs20` yet because nodejs has some break change.
## Start the development server
```bash
pnpm install
pnpm dev
```
You can edit the configuration of `server/.env` to your own relevant context
The file can be started from `server/.env.example`
Now you can preview your server in `http://localhost:11011`
## Project directory description
- `apps`: non-core applications
- `cli`: Tailchats command line program
- `github-app`: Tailchats github integration bot
- `oauth-demo`: Tailchat open platform third-party login demo program
- `widget`: Web page embedded widget
- `client`: client
- `desktop`: desktop version
- `mobile`: mobile version
- `packages`: dependency packages
- `shared`: platform-independent common code
- `web`: web version
- `plugins`: pure frontend plugins
- `src`: source code
- `packages`
- `types`: common types for both front and back ends
- `server`: server
- `admin`: background management
- `models`: database model
- `plugins`: server-side plugins
- `services`: microservices
- `website`: official website

View File

@@ -0,0 +1,187 @@
---
sidebar_position: 4
title: Docker Compose deployment
---
## Recommended configuration
Recommended minimum configuration **1 core 2G**
> If there is only **1 core 1G**? Please refer to my blog: [Linux small resource server experience summary](http://moonrailgun.com/posts/6769ba51/) expand memory space by swapping memory
>
> Memory usage for reference:
> ![](/img/misc/memory-usage.png)
## Pre-environment
### Docker / Docker Compose
First you need to make sure you have a `Docker / Docker Compose` environment
The installation method can refer to: [Install the docker environment](./install-docker.md)
## Pull Image
You can pull the compiled image from **public image** or **manually compile from source code**
> Using the compiled image can compile without spending enough computer resources, which is very friendly to servers with small resource configurations. In addition, compared to source code compilation, the code of the public image is more stable.
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
<Tabs groupId="build">
<TabItem value="cli" label="One-command installation using cli" default>
> Use `cli` Please make sure you already have a node environment on your server (node version 16+ is recommended)
> If you don't know about node, you can use `Manually install from public image`
Use the command line tool `tailchat-cli` to pull/update the image with one click:
```bash
npx tailchat-cli docker update
```
</TabItem>
<TabItem value="public-image" label="Manually install from public image" default>
Manually install using Docker native commands:
```bash
docker pull moonrailgun/tailchat # Pull the tailchat image from the public image registry
docker tag moonrailgun/tailchat tailchat # Retag the downloaded image to tailchat (consistent with source code compilation, if not changed, it will follow the source code compilation process)
```
:::info
You can view historically supported image versions from [Docker Hub](https://hub.docker.com/r/moonrailgun/tailchat/tags)
:::
</TabItem>
<TabItem value="source-code" label="Compile from source">
*This section is for advanced players to get the latest tailchat implementation, please make sure you have enough knowledge of `docker`, `nodejs`, `git`*
#### Compilation environment
- Download from [official website](https://nodejs.org/en/download/)
- Or use [nvm](https://github.com/nvm-sh/nvm)
#### Install pnpm
`pnpm` is a package management tool for `nodejs`, a substitute for `npm`, in order to ensure the same dependency environment as developers, it is strongly recommended that you use pnpm as a follow-up package management tool
```bash
npm install -g pnpm
```
#### Clone Repo
Download the project from remote:
```bash
mkdir msgbyte && cd msgbyte
git clone https://github.com/msgbyte/tailchat.git # Clone the project to local
```
#### Compile project
```bash
cd tailchat && docker compose build
```
*Compilation has certain requirements on server configuration, 2-core 4G compilation takes about 10 minutes, for reference*
After the compilation is complete, you can view the compiled image through `docker images`.
</TabItem>
</Tabs>
## Startup project
<Tabs groupId="build">
<TabItem value="cli" label="One-command installation using cli" default>
```bash
npx tailchat-cli docker init
```
Executing this command will ask you some configuration-related questions in an interactive manner (as shown in the figure below), and the configuration file will be automatically generated after filling it out
![](./assets/docker-init.png)
</TabItem>
<TabItem value="public-image" label="Manually install from public image">
> A configuration file needs to be downloaded before starting to tell `docker-compose` how to start the image
> Download configuration files and configure environment variables from the repository:
> - [docker-compose.yml](https://raw.githubusercontent.com/msgbyte/tailchat/master/docker-compose.yml)
> - [docker-compose.env](https://raw.githubusercontent.com/msgbyte/tailchat/master/docker-compose.env)
```bash
mkdir tailchat && cd tailchat
wget https://raw.githubusercontent.com/msgbyte/tailchat/master/docker-compose.yml
wget https://raw.githubusercontent.com/msgbyte/tailchat/master/docker-compose.env
```
Need to modify the configuration before starting
Modify the configuration of the `docker-compose.env` file, the following fields are recommended to be modified:
- `API_URL` is an externally accessible url address, used for file service access, it can be a domain name or an ip **If the sent picture cannot be displayed normally, this variable is not set**
- `SECRET` server-side encryption key, used to generate Token. The default is `tailchat`
</TabItem>
<TabItem value="source-code" label="Compile from source">
Need to modify the configuration before starting
Modify the configuration of the `docker-compose.env` file, the following fields are recommended to be modified:
- `API_URL` is an externally accessible url address, used for file service access, it can be a domain name or an ip **If the sent picture cannot be displayed normally, this variable is not set**
- `SECRET` server-side encryption key, used to generate Token. The default is `tailchat`
</TabItem>
</Tabs>
After completing the configuration, use `docker-compose` to start the `Tailchat` application with one click:
```bash
# Make sure the configuration files (docker-compose.yml and docker-compose.env) are in the current directory
# Execute the following command to start with one key
docker compose up -d
```
Visit: `http://<server ip>:11000` to open tailchat.
Note that some cloud services may need to manually open firewall ports.
*Some environment variables are provided in the `docker-compose.env` file for configuration.*
The `docker-compose.yml` configuration of `tailchat` provides the following configuration by default:
- `mongodb`: Persistent Database
- `redis`: KV database and message transport service
- `minio`: Distributed file service
The persistent files (database, file storage) are managed uniformly through `docker volume`:
```
docker volume ls | grep "tailchat-server"
```
:::info
Complete environment variables can be queried [Environment Variables](./environment.md)
:::
## More deployment related documents
- [Build https gateway (optional)](./https-gateway.md)
- [Deployment admin platform (optional)](./admin.md)

View File

@@ -0,0 +1,79 @@
---
sidebar_position: 7
title: Environment Variable
---
## Environment Variable
| Name | Default Value | Description |
| ----- | ------ | --- |
| PORT | 11000 | Gateway service port number |
| SECRET | tailchat | encryption key, used for JWT |
| STATIC_HOST | "{BACKEND}" | Externally accessible static service host, used for file service access, the default is the dynamic server address inferred from the front-end request, if it is expected to be stored in a third-party OSS, it needs to be modified |
| STATIC_URL | "{BACKEND}/static/" | Externally accessible static service complete address prefix, used for file service access, the default is the dynamic server address inferred from the front-end request, if it is expected to be stored in a third-party OSS Modify, if this variable is set, the above `STATIC_HOST` value is invalid |
| API_URL | http://127.0.0.1:11000 | Externally accessible url address, used for issuer issuance on open platforms or as a fallback for file services |
| MONGO_URL | - | Database service address |
| REDIS_URL | - | Redis service address |
| MINIO_URL | - | File service address (minio) |
| MINIO_USER | - | File service username |
| MINIO_PASS | - | File service password |
| MINIO_BUCKET_NAME | tailchat | file service bucket name |
| MINIO_PATH_STYLE | false | Whether to use path-style s3 communication format, `true` is `Path Style`, `false` is `Virtual hosted style` |
| MINIO_SSL | false | Whether to use SSL to connect storage, if "1" or "true" enable SSL |
| SMTP_SENDER | - | Mail service sender (example: `"Tailchat" example@163.com`) |
| SMTP_URI | - | mail service connection address (example: `smtp://username:password@smtp.example.com/?pool=true`) |
| FILE_LIMIT | 1048576 | File/image upload size limit, the default is 1m, please enter a number(unit: byte) |
| EMAIL_VERIFY | - | Whether to enable email verification, if it is "1" or "true", add email verification control when registering |
| REQUEST_TIMEOUT | 10000 | Number of milliseconds to wait before reject a request with a RequestTimeout error. Disabled: 0 |
| TIANJI_SCRIPT_URL | - | Script Url of Tianji if you wanna monitor Tailchat user usage, you can get it in code modal in Tianji website (example: `https://tianji.example.com/tracker.js`) |
| TIANJI_WEBSITE_ID | - | Tianji website id |
| DISABLE_MESSAGEPACK | - | Whether to disable using messagepack as [parser](https://socket.io/docs/v4/custom-parser/) for socketio in openapi, if "1" or "true" turn off this method |
| DISABLE_LOGGER | - | Whether to disable the log output, if "1" or "true" turn off the log on the fly |
| DISABLE_TRACING | - | Whether to disable the Tracing function (enabling it can save a lot of logs), if "1" or "true" turn off the log on the fly |
| DISABLE_USER_REGISTER | - | Whether to disable the user register, if "1" or "true" turn off this method |
| DISABLE_GUEST_LOGIN | - | Whether to disable the guest login, if "1" or "true" turn off this method |
| DISABLE_CREATE_GROUP | - | Whether to disable user create group, if "1" or "true" turn off this method |
| DISABLE_PLUGIN_STORE | - | Whether to hide user plugin store entry, if "1" or "true" turn off this method |
| DISABLE_ADD_FRIEND | - | Whether to hide user add friend entry, if "1" or "true" turn off this method |
| DISABLE_TELEMETRY | - | Whether to disable send telemetry report to msgbyte to help us improve, its anonymous, if "1" or "true" turn off telemetry |
> Some examples of environment variables can be seen: https://github.com/msgbyte/tailchat/blob/master/server/.env.example
### Use files to configure environment variables
- - If starting locally, copy `.env.example` to `.env` and edit
```bash
mv .env.example .env
vi .env
```
- If it is started by `docker-compose`, you can directly edit `docker-compose.env`, and use `docker compose up -d` directly after the modification to take effect
### About the use of environment variables with spaces
If your environment variable value contains spaces, in order for the system to recognize that this is a complete string instead of treating spaces as separators. You need to wrap a double quotes around the outside.
For example:
```bash
SMTP_SENDER="\"Tailchat\" example@163.com" # If there are repeated double quotes, they need to be escaped with an escape character
```
-------------
:::caution
Some environment variable modifications may need to clear the cache to take effect
:::
### How to clear the cache
Changes to some environment variables may involve cache updates, such as `FILE_LIMIT`, because config data needs to be sent to the client.
Therefore, it may appear that after modifying the environment variable, the performance on the client is still the same as before. At this point you need to clear the old cache for the update to take effect.
There are several options for clearing the cache:
- Execute `docker compose down` then run `docker compose up -d`. This is because the data of the `redis` service is not persisted, shutting down and restarting the service is equivalent to a brand new environment
- Manually enter the `redis` service to clean up the cache items whose name contains `config.client`, which contains the configuration items returned to the client
- Enter the cache management page of the `admin` management system. Click the `Clean Configuration Cache` button

View File

@@ -0,0 +1,45 @@
---
sidebar_position: 8
title: Build https gateway (optional)
---
In `Tailchat`, some services are strongly dependent on `https`, such as audio and video calls, embedding external `https` media resources and web pages, etc.
At the same time, for the safety of users(client to server), we highly recommend that `Tailchat` be provided externally as `https` service.
![](/img/architecture/https-gateway.excalidraw.svg)
If you have no related experience, and only deploy `Tailchat` service on the same machine (without occupying **80**/**443** port), then we recommend `swag` from `Tailchat` Configuration begins.
:::info
You can see the original configuration in [Github](https://github.com/msgbyte/tailchat/tree/master/docker)
:::
Pull the required configuration file directly by the following command
```bash
wget https://raw.githubusercontent.com/msgbyte/tailchat/master/docker/swag.yml
wget https://raw.githubusercontent.com/msgbyte/tailchat/master/docker/swag.env.example -O swag.env
mkdir config
wget https://raw.githubusercontent.com/msgbyte/tailchat/master/docker/config/nginx.conf -O ./config/nginx.conf
```
After completion, you should see the following three files in the current directory:
- `swag.yml`
- `swag.env`
- `config/nginx.conf`
Modify the content of `swag.env`, change the value of `URL` to the domain name, such as: `URL=tailchat.example.com`
:::info
The `https` protocol relies on the domain name for certificate verification, so it is necessary to assign a domain name in advance to point to the target server
:::
The address of the domain name needs to create an A pointing record in the management background of the purchased domain name.
After assigning the domain name we can start the service.
```bash
docker compose -f ./swag.yml up -d
```
If everything goes well, the `swag` service has automatically applied for a certificate for you and started the reverse proxy service. At this time, if you visit `https://tailchat.example.com` in the browser, you can see the familiar The interface is already there.

View File

@@ -0,0 +1,80 @@
---
sidebar_position: 2
title: Install the docker environment
---
> Because the `Tailchat` environment is a bit complicated for beginners, it provides a `docker-based one-command` environment configuration. But for students who are not familiar with `docker`, `docker` itself may also be a kind of complexity.
> Therefore, in order to facilitate everyone to quickly build `Tailchat`, this article is provided as a guide. Students who have a certain understanding of `docker` can skip this article
> This article takes `linux centos` as an example, the goal is to facilitate the deployment directly on the server. For students who want to use it on other systems (`windows`, `mac`), you can refer to the official documentation to install `docker`
## One-command installation of docker
Officially maintained one-command installation `Docker` script, suitable for students who dont like to study details
Execute the following operations in sequence on the server terminal
```bash
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
```
If the installation is successful, you can skip the subsequent content.
## Manually install docker and docker compose
Official document: [https://docs.docker.com/engine/install/](https://docs.docker.com/engine/install/)
```bash
# If you have installed docker before, you can execute the following command to delete the old one
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
```
```bash
sudo yum install -y yum-utils # yum-utils provides the yum-config-manager command
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
```
> Install docker and docker-compose plugins
```bash
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
```
*PS: `docker-compose-plugin` provides the `docker compose` command, the usage is the same as `docker-compose`*
> If `docker ps` shows that the daemon process is not started (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?), you can execute the following command to start it: `sudo systemctl start docker`
## Install docker-compose separately
If the purchased server has been pre-installed with docker, if you want to install docker-compose separately, you can read this section:
Official document: [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)
```bash
curl -SL https://github.com/docker/compose/releases/download/v2.4.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose # Download binaries
sudo chmod +x /usr/local/bin/docker-compose # give execute permission
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose # Soft link to path, can be called directly
docker-compose --version # The line command returns the version number and the installation is successful
```
## NOTICE
For historical reasons, `docker compose` has a `docker` plugin version and a `docker compose` standalone version. Generally speaking, `docker compose xxx` is equivalent to `docker-compose xxx`
## Reference
- [Docker](https://docs.docker.com/engine/install/)
- [Docker Compose](https://docs.docker.com/compose/install/)

View File

@@ -0,0 +1,155 @@
---
sidebar_position: 12
title: Mobile Self Compile (optional)
---
The source code of `Tailchat` mobile terminal is located in `client/mobile`. The technology stack is `react-native`
You can download the compiled general version directly from the official website: [https://tailchat.msgbyte.com/downloads](https://tailchat.msgbyte.com/downloads), or compile it yourself from the source code
This section mainly explains how to compile the mobile version of `Tailchat`.
## Prepare the development environment
You can see the complete development environment preparation operation at [https://reactnative.dev/docs/environment-setup](https://reactnative.dev/docs/environment-setup), so I wont go into details here.
### Install dependencies
```bash
cd client/mobile
yarn
```
### Environment check
```bash
yarn doctor
```
## Prepare environment variables
```bash
cp.env.example.env
```
In the `.env` file we configure the required environment variables for compilation
```ini
TAILCHAT_UPLOAD_STORE_FILE=
TAILCHAT_UPLOAD_STORE_PASSWORD=
TAILCHAT_UPLOAD_KEY_ALIAS=
TAILCHAT_UPLOAD_KEY_PASSWORD=
GETUI_APPID=
GETUI_APPKEY=
GETUI_APPSECRET=
GETUI_HUAWEI_APP_ID=
```
## Certificate signing
If you are only using it for testing, you can skip this section and Tailchat will sign it for you using a public test certificate.
### Android
If you need to use your own certificate for signing, you need to fill in the following:
```ini
TAILCHAT_UPLOAD_STORE_FILE=
TAILCHAT_UPLOAD_STORE_PASSWORD=
TAILCHAT_UPLOAD_KEY_ALIAS=
TAILCHAT_UPLOAD_KEY_PASSWORD=
```
Need to fill in: certificate file name, password, alias, alias password
The certificate file needs to be placed in the `client/mobile/android/app` directory, usually a `*.keystore` file
> As for how to generate it, you can use `Android Studio` or `keytool` tool to generate it.
### iOS
TODO
## Push
`Tailchat` implements Android multi-vendor message push by integrating personal tweets as a relay
You can get all the required configuration in the application configuration of `getui`
Among them `GETUI_APPID`, `GETUI_APPKEY`, `GETUI_APPSECRET` are filled in in order
Corresponding configuration is required on the server side `GETUI_APPID`, `GETUI_APPKEY`, `GETUI_MASTERSECRET` so that the self-deployed push service can send push messages correctly
![](/img/misc/getui.png)
### Manufacturer Push
Manufacturer push can be turned on or off as needed
The source code needs to be modified as follows:
- `manifestPlaceholders` section and `dependencies` section of `client/mobile/android/app/build.gradle`
- `.env` environment variable configuration
## Compile
### Android
```bash
cd android
./gradlew assembleRelease
```
### iOS
iOS compilation needs to be done through `xcode`
> Screenshot cannot be taken due to lack of equipment, please follow the public information on the Internet.
### FAQ
If the following types of errors occur:
```
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not create task ':app:generateDebugLintModel'.
> java.lang.NullPointerException (no error message)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 27s
```
It may be because your environment variable is missing, you can leave the value empty, but the entry must exist
like:
```ini
GETUI_APPID=xxxxxxxxxxxx
GETUI_APPKEY=yyyyyyyyy
GETUI_APPSECRET=zzzzzzzzzz
GETUI_HUAWEI_APP_ID=
```
instead of
```ini
GETUI_APPID=xxxxxxxxxxxx
GETUI_APPKEY=yyyyyyyyy
GETUI_APPSECRET=zzzzzzzzzz
```
#### Can I compile it myself and publish it to the app store?
Yes, but please modify the application name, package name, icon and other information to prevent conflicts with official applications.

View File

@@ -0,0 +1,4 @@
{
"label": "Install with other ways",
"position": 5
}

View File

@@ -0,0 +1,10 @@
---
sidebar_position: 3
title: Install with BT
---
:::info
This document is only available for Chinese.
:::
If you are chinese user, and wanna install Tailchat with bt, please learn more with switch language to chinese and read it.

View File

@@ -0,0 +1,4 @@
{
"label": "Kubernetes",
"position": 2
}

View File

@@ -0,0 +1,147 @@
---
sidebar_position: 2
title: Deployment in sealos
---
`Sealos` is an open-source Kubernetes deployment system that allows us to quickly create an on-demand, pay-as-you-go application cluster.
## First, enter Sealos and open "Application Management"
![](/img/kubernetes/sealos/1.png)
## Create a new application
![](/img/kubernetes/sealos/2.png)
### Create dependencies
As an enterprise-level application, `tailchat` has the minimum dependencies of `mongodb`, `redis`, and `minio`. Let's create them one by one.
#### MongoDB
For convenience, we will fix one instance and bind it to local storage. The image used is `mongo:4`. Note that because we did not set a password for the database, do not provide network services to the public network. The container exposes port 27017, which is the default database service port. The content is as follows:
![](/img/kubernetes/sealos/3.png)
Click "Deploy Application" to submit the deployment. Wait patiently for a while, and you can see that the application has started up.
![](/img/kubernetes/sealos/4.png)
> Note: that the initial allocation of 64m is too small for MongoDB, so I changed it to 128m by modifying the application. Resource allocation can be changed at any time, which is also a convenient feature of Sealos/Kubernetes.
#### Minio
Next, we will create Minio, an open-source object storage service. We can also quickly create it through Sealos's UI. The image used is `minio/minio`. Note that we need to make some adjustments:
- Expose port: 9000
- Change the run command to: `minio`
- Change the command parameters to: `server /data`
- Set environment variables:
- MINIO_ROOT_USER: tailchat
- MINIO_ROOT_PASSWORD: com.msgbyte.tailchat
- Local storage: `/data`
The final result is as follows:
![](/img/kubernetes/sealos/5.png)
Click the "Deploy" button and you can see that the service has started up normally.
#### Redis
Finally, we need to deploy Redis as a content cache and message forwarding. The image used is `redis:alpine`, and the exposed port is `6379`. The final result is as follows:
![](/img/kubernetes/sealos/6.png)
### Create Tailchat itself
At this point, all the dependencies required by Tailchat have been deployed, as shown below:
![](/img/kubernetes/sealos/7.png)
Now we can deploy the Tailchat itself. The Tailchat itself will be relatively complex, but because Sealos is purely UI-based, it will not be too complicated.
- Use image: `moonrailgun/tailchat`
- Expose port: `11000` (remember to open external access)
- Configure environment variables as follows:
```
SERVICEDIR=services,plugins
TRANSPORTER=redis://redis:6379
REDIS_URL=redis://redis:6379
MONGO_URL=mongodb://mongo/tailchat
MINIO_URL=minio:9000
MINIO_USER=tailchat
MINIO_PASS=com.msgbyte.tailchat
```
The final effect is as follows:
![](/img/kubernetes/sealos/8.png)
After waiting patiently for a while, you can see that the Tailchat service has started up.
![](/img/kubernetes/sealos/9.png)
## Preview service
First, we can check the availability of the Tailchat service by adding `/health` to the external address provided by the service, such as `https://<xxxxxxxxxx>.cloud.sealos.io/health`. When it starts up, the Tailchat service will return content like this:
![](/img/kubernetes/sealos/10.png)
This JSON string contains the image version used, node name, system usage, and microservice loading status. Here we can see that my common services, such as `user`/`chat.message`, and some services with plugin prefixes such as `plugin.registry`, have all started up normally, indicating that our server is running normally. Now we can directly access our external address and see that after a short loading time, the page opens normally and automatically jumps to the login page.
![](/img/kubernetes/sealos/11.png)
Register an account casually, and you can see that we can enter the main interface of Tailchat normally, as shown in the following figure:
![](/img/kubernetes/sealos/12.png)
At this point, our service has successfully landed in Sealos.
## Scaling service
Of course, as a distributed architecture system, Tailchat naturally supports horizontal scaling. In Sealos, scaling is also very simple. Just modify the number of instances through the change operation:
![](/img/kubernetes/sealos/13.png)
![](/img/kubernetes/sealos/14.png)
![](/img/kubernetes/sealos/15.png)
At this point, when we access `https://<xxxxxxxxxx>.cloud.sealos.io/health`, we can see that we can access different nodes.
![](/img/kubernetes/sealos/16.png)
## Add Tailchat entry to desktop
Open Terminal, enter `vim app.yml` to create and edit a configuration file
Enter the following content, note that the url should be replaced with the url deployed by yourself
```yml
apiVersion: app.sealos.io/v1
kind: App
metadata:
name: tailchat-app-entry
spec:
name: Tailchat
icon:
type: iframe
data:
url: <Your url>
desc:
icon: https://tailchat.msgbyte.com/img/logo.svg
menuData:
nameColor: text-black
helpDropDown:
helpDocs:
displayType: normal
```
Press `esc` to exit edit mode, press `:wq` to save and exit vim
Type `kubectl apply -f app.yml` to start the configuration.
After refreshing the page, we can see that our entry appears on the desktop of `sealos`
![](/img/kubernetes/sealos/17.png)

View File

@@ -0,0 +1,117 @@
---
sidebar_position: 1
title: Simple Deployment
---
## Introduction
Kubernetes is an open-source container orchestration platform used for automating the deployment, scaling, and management of containerized applications. It provides a way to orchestrate containers, automating tasks such as deployment, scheduling, load balancing, and fault recovery, making containerized applications run efficiently in a distributed system.
Advantages of Kubernetes include:
- Automation: Kubernetes automates tasks such as deployment, scheduling, load balancing, and fault recovery, reducing the amount of manual work required.
- Scalability: Kubernetes can manage thousands of containerized applications in large-scale clusters, with good horizontal and vertical scalability.
- Flexibility: Kubernetes supports multiple container runtimes and multiple cloud platforms, allowing applications to be deployed and managed in different environments.
- Reliability: Kubernetes provides powerful fault recovery mechanisms and self-healing capabilities, ensuring high availability and reliability of applications.
- Community support: Kubernetes is an active open-source project with a large community support and ecosystem, allowing for quick updates and support.
## Quick Start
If you want to deploy the Tailchat project on Kubernetes, you can find the prepared simple Tailchat deployment configuration in the `docker/simple/k8s` subdirectory of the project directory. These configuration files include Kubernetes resource definitions for running Tailchat, such as StatefulSet, Service, and dependencies such as databases and persistent storage. These resource definitions allow you to quickly deploy a simple Tailchat project on Kubernetes without manually creating and configuring these resources.
:::info
Note that the deployed Tailchat in this tutorial does not include the complete Tailchat ecosystem, such as the **Open Platform** and **Admin Management Platform**.
:::
### Environment Dependencies
To start this chapter, we assume that you have a working Kubernetes environment ready. This section does not describe how to set up a k8s environment.
### Getting Started
First, we need to clone the project repository:
```bash
git clone git@github.com:msgbyte/tailchat.git
```
Change the working directory to the configuration file directory:
```bash
cd docker/simple/k8s
```
At this point, you can see many prepared configuration files, and we can start by running a single command:
```bash
kubectl apply -f namespace.yml -f pv.yml -f mongo.yml -f minio.yml -f redis.yml -f tailchat.yml
```
This command will create the `namespace`, create `pv` and `pvc`, create `mongodb`, `minio`, `redis`, and other necessary third-party middleware, and finally start a multi-instance `tailchat` service.
You can check the status of each service using the following command:
```bash
kubectl get svc -n tailchat
```
### Routing and Load Balancing
When all services are ready, our Tailchat service is now running in the cluster, but we cannot access it because it has not been exposed to the outside.
For local testing, we can use the `port forward` function to map the port of a pod to the local machine. In a production environment, however, we need to build routing and forwarding.
Taking `traefik` as an example:
> Traefik is an open-source reverse proxy and load balancer designed specifically for routing and load balancing traffic in containerized applications and microservices architectures. Traefik supports multiple backend services, including Docker, Kubernetes, Mesos, Swarm, Consul, Etcd, and more. It can automatically discover and configure backend services and route traffic to the corresponding service instances based on rules.
#### Installing Helm and Adding Repository Address
The installation of `helm` is not discussed here. We execute the following command to add `traefik` to the repository list:
```bash
helm repo add traefik https://helm.traefik.io/traefik
```
#### Installing Traefik in the Tailchat Namespace
```bash
helm install traefik traefik/traefik -n tailchat
```
#### Starting Ingress Resource Declaration
```bash
kubectl apply -f ingress.yml
```
If everything is ok, you can see the following output using the following command:
```bash
kubectl get services -n tailchat
```
![](/img/kubernetes/traefik-svc.png)
#### Setting up DNS Services
You can modify the domain address configuration in the `ingress.yml` mentioned above, which defaults to `http://tailchat.internal.com/`.
If you do not wish to modify or do not have a domain name, you can modify the `hosts` file to achieve this:
```bash
sudo vim /etc/hosts
```
Then add the following path:
```
127.0.0.1 tailchat.internal.com
```
Now you can open your browser and visit `http://tailchat.internal.com` to access the Tailchat service deployed on Kubernetes.
Of course, you can also check the availability of the service by visiting the following address:
```
http://tailchat.internal.com/health
```

View File

@@ -0,0 +1,87 @@
---
sidebar_position: 1
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

View File

@@ -0,0 +1,26 @@
---
sidebar_position: 1
title: Quick Start
---
## Demo environment
The demo environment will continuously deploy the latest front-end code and update the back-end code from time to time
[https://nightly.paw.msgbyte.com/](https://nightly.paw.msgbyte.com/)
## Deployment method
### Docker/Docker Compose
It is highly recommended to use `docker-compose` to deploy `tailchat`
Please refer to the tutorial: [Docker Compose Deployment](./docker-compose.mdx)
### Kubernetes
Please refer to the tutorial: [Kubernetes Simple Deployment](./other-way/kubernetes/simple.md)
## System Structure
See [System Architecture](../architecture.md)

View File

@@ -0,0 +1,46 @@
---
sidebar_position: 10
title: SMTP Service (optional)
---
`Tailchat` includes email services, used in scenarios such as **password recovery**, **mail authentication**
Only simple mail service (SMTP) is used in `Tailchat` because only one-way sending mail is required and no receiving mail is required.
In order to enable the service, we need to set the following in the environment variable:
- `SMTP_SENDER`: sender information, the general format is `xxx@example.com` or `"YourName" xxx@example.com`
- `SMTP_URI`: SMTP mail service address, follow the international common URI format: `<protocol>://<username>:<password>@<host>:<port>/<other-info>`
## Auxiliary testing using cli
If you are not familiar with SMTP service, in order to improve detection efficiency, you can choose to use `tailchat-cli` to quickly help you verify the reliability of SMTP service
> For usage of tailchat-cli, see [tailchat-cli](../cli/tailchat-cli.md)
```
tailchat smtp
SMTP Service
Commands:
tailchat smtp verify Verify smtp sender service
tailchat smtp test Send test email with smtp service
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
```
You can verify URI availability with `tailchat smtp verify`, no email is actually sent during this operation. Similar to account login
If there are still problems after the verification is passed, you can use `tailchat smtp test` to actually send a test email to help you troubleshoot the problem, because there are many possibilities in the actual production environment, such as bounced letters caused by audit problems of various service providers, such as The degree of verification is different. For example, some service providers allow custom sender names, and some have strict requirements on them.
## SMTP_URI example
Because the services provided by different service providers are different, only some of the content can be cited here for demonstration. If you have other URIs that can be used as examples, please submit a PR to help us improve the documentation together:
- `smtps://<username>:<password>@smtp.exmail.qq.com/?pool=true`
- `smtps://<username>:<password>@smtp.163.com/?pool=true`
- `smtps://<qqNumber>:<password>@smtp.qq.com/?pool=true`

View File

@@ -0,0 +1,103 @@
---
sidebar_position: 50
title: Troubleshooting
---
## Deployment related
### How to update the version?
It is the same as getting the image when deploying
```bash
docker pull moonrailgun/tailchat
docker tag moonrailgun/tailchat tailchat
```
Then restart the application, such as `docker compose up -d`
### How to use the specified version?
```bash
docker pull moonrailgun/tailchat:1.8.4
docker tag moonrailgun/tailchat:1.8.4 tailchat
```
Just specify the version number when pulling the image
## Server related
### The Websocket connection access is incorrect, the manifestation is that it can be registered but the main interface cannot be opened
If nginx is used for reverse proxy. Please ensure that the configuration of nginx supports websocket, a reference configuration is as follows:
```
server {
server_name demo.example.com;
listen 443 ssl;
access_log /var/log/nginx/host.access.log main;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_pass http://127.0.0.1:11000/;
}
}
```
### Internal Network can be accessed but External Network can not be accessed?
You can start a simple http service to see if it is a problem with the docker-proxy layer. *This problem may occur on the docker-ce image machine of Tencent lighthouse, you can choose to use the centos7 image to reinstall*
```bash
docker run --rm --name nginx-test -p 8080:80 nginx
```
### There will be a random hash volume at startup
See: [https://github.com/msgbyte/tailchat/issues/79](https://github.com/msgbyte/tailchat/issues/79)
### Getting `502 Invalid paramenters` when sending mail
If the prompt is similar to: `Error: Mail command failed: 502 Invalid paramenters`
```
code:'EENVELOPE',
response: '502 Invalid paramenters',
responseCode: 502,
command: 'MAIL FROM'
```
Please check whether your `SMTP_SENDER` content is correct, the general format is `xxx@example.com` or `"YourName" xxx@example.com`
### Openapi service is always restart
If this throw error `Issuer Identifier must be a valid web uri`
you should make sure has been writing a url(`http://xxxx` or `https://xxxx`) in env `API_URL`
## Openapi platform related
If the open platform is deployed behind a proxy, if the endpoint in the JSON of the access `/open/.well-known/openid-configuration` result is incorrect, please try to modify the configuration of the proxy to forward real ip.
Such as nginx:
```
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:11000;
proxy_redirect off;
}
```