Server Deployment Guide#
Docker (Recommended)#
For this project, we provide two docker images for use in production environments: one based on Debian and another based on Alpine. The Alpine series images are suitable for scenarios where disk space is precious.
Apart from the operating system differences, there are several different tags to choose from:
nightly: The latest version built on the main branch, built once a day, may be unstable but has the latest changes
latest: The latest stable version
Other version images, such as v0.1.0.beta, represent images of specific versions
Here are the specific steps to follow:
alpine
cd docker && docker compose up -d
debian
cd docker && docker compose -f compose.debian.yml up -d
Completing this step only creates a very basic environment, but the security is far from adequate. To ensure security, you need to change the passwords for PostgreSQL and Redis.
Here are the specific steps:
(If you are using the Debian series image, all references to compose.yml below refer to compose.debian.yml)
Change the
123456forPOSTGRES_PASSWORDincompose.ymlto your own strong passwordChange the
123456indocker/config/redis.confto your own strong passwordChange the
123456forRABBITMQ_DEFAULT_PASSincompose.ymlto your own strong passwordChange the password in
docker/config/database.tomlto the new PostgreSQL passwordChange the password in
docker/config/redis.tomlto the new Redis passwordChange the password in
docker/config/rabbitmq.tomlto the new Rabbitmq passwordRun your docker environment startup command again
After completing these steps, you have successfully deployed the project.
For data in the container, we have mapped it to data, so you can save data at any time
Manual Deployment#
For computers with low performance and no Docker installed, we also provide documentation for manual deployment. For this, it is recommended to deploy in a Linux environment, as other environments have not been rigorously tested.
install PostgreSQL#
The postgres version is 17 (If this document is not updated in time, you can check the ‘postgres version’ in the compose.yml file)
Install Redis#
The redis version is 7 (If this document is not updated in time, you can check the redis version incompose.yml file)
Install OurChat server#
There are two alternative options here:
1.(推荐)从 github release 下载最新的 linux 编译结果,如果遇到 CPU 架构和其他兼容性问题,可能需要手动编译,参见下一节
2.手动编译
Pull the source code:
git clone https://github.com/SkyUOI/OurChat --depth=1 && cd OurChat
Install the Rust toolchain
Compile the project
cd server && cargo build --release
Run the project
Please refer to the Server Arguments for this step, and the executable file is located at target/release/server
Please note that server passwords and other settings still need to be modified!
Being integrated with nginx#
Due to the fact that grpc is based on http2, the http2 on; parameter is enabled, and newer versions of nginx provide the grpc_pass parameter to forward traffic, so the following example configuration is provided:
server {
server_name xxx.com;
location / {
grpc_pass grpc://127.0.0.1:17777;
}
http2 on;
listen 7777;
}
However, OurChat has some functions based on long-term open streams, due to the fixed time termination of unused streams by nginx, which may cause inconvenience. Therefore, it is recommended to increase it to between 10 minutes and 1 hour. The following updated configuration is provided. Note: This setting must be enabled in almost all cases, otherwise the client may not work properly:
server {
server_name xxx.com;
location / {
grpc_pass grpc://127.0.0.1:17777;
}
http2 on;
keepalive_timeout 1200s; # Added
grpc_read_timeout 1200s; # Added
listen 7777;
}
Since the default maximum transfer limit of nginx is 1MB, a 413 Content Too Large error will be triggered when transferring files larger than 1MB, resulting in the inability to transfer large files. Therefore, the following configuration is required.
server_name xxx.com;
location / {
grpc_pass grpc://127.0.0.1:17777;
}
http2 on;
keepalive_timeout 1200s;
grpc_read_timeout 1200s;
client_max_body_size 2048M # Added
listen 7777;
SSL/TLS Encryption#
Please see SSL/TLS