Many friends have had the idea to build their own chat service application, get rid of wechat, QQ and other third-party applications, pay more attention to their own privacy, or better storage of their own files.

I found RocketChat, an open source chat app that enables group chat, direct communication, private chat groups, desktop notifications, media embedding, link previews, file uploads, voice/video chat, screenshots, and more, as well as real-time translation and automatic real-time message conversion between users. RocketChat gives you complete control over ac communication.

To prepare

The function sounds good, let’s build it together, I use the following configuration:

1.CentOS 7.6 1CPU/2G/60G 2 Open port 3000 on the public networkCopy the code

In addition, it is necessary to set up the Docker runtime environment, which has been described in the previous tutorial to use one-click scripts. If you are not clear, you can refer to the previous tutorial.

[root@mx ~]# docker -v
Docker version 20.10.9, build c2ea9bc
[root@mx ~]# 
Copy the code

The deployment of

Deploy the mongo

Start by creating a custom network for isolated access between containers.

Docker network create --subnet=172.18.0.0/16 mynet e931682423fb3ce386fe8ccff2d4a1207a49de0f6cbb938290aaf94a680d2e33 [root@mx ~]# docker network ls NETWORK ID NAME DRIVER SCOPE a187d39a9c31 bridge bridge local a009b92afbec host host local e931682423fb mynet bridge local f7101068a933 none null local [root@mx ~]#Copy the code

image

RocketChat relies on the MongoDB runtime environment and is deployed in Docker mode

Mkdir -p/opt/docker/mongo # create a vim configuration file/opt/docker/mongo/mongod. ConfCopy the code

Here is the contents of mongod. Conf, paste it into the file, then use ESC and 😡 to save and exit.

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /data/db
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

#security:
#  authorization: "enabled"

#operationProfiling:

replication:
  replSetName: "rs01"

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:
Copy the code

Use the following command to create a run image.

Docker run \ -itd \ -e PGID=1000 \ -e PUID=1000 \ --name=MongoDB \ --net=mynet \ -- IP =172.18.0.2 \ -e TZ=Asia/Shanghai \  -p 27017:27017/tcp \ -v /opt/docker/mongodb/:/data/db:rw \ --hostname mongodatabase mongo \ -f /data/db/mongod.confCopy the code

Because the image server of Docker is in a foreign country, so the download is slow. If you encounter the following error, please try several times.Run commands to check the running status. If no other error is reported, the installation is normal.

# View the container docker PS runningCopy the code

image

Configuration mongo

We need to do a number of configurations for MongoDB.

[root@mx ~]# docker exec -it MongoDB bash root@mongodatabase:/# # MongoDB root@mongodatabase:/# mongo # Mongodatabase :SECONDARY> rs.initiate() {" OK ": 0, "errmsg" : "already initialized", "code" : 23, "codeName" : "AlreadyInitialized", "$clusterTime" : { "clusterTime" : Timestamp(1635072585, 2), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1635072585, Mongodatabase :PRIMARY> use admin to mongodatabase: switched db mongodatabase:PRIMARY> Db. CreateUser ({user: "root", PWD: "admin123",roles: [{role: "root", db: "admin"}]}) db.createUser({user: "rocketchat",pwd: "admin123",roles: [{role: "readWrite", db: * * * * * * * * * * * * * * * * * * * * * * * * "rocketchat" }]})Copy the code

If your results are similar to mine, congratulations.Using exit to exit mongodb and the container, we modify a configuration.

docker stop MongoDB
vim /opt/docker/mongodb/mongod.conf 
Copy the code

Uncomment lines 24-25, save the Settings, and restart mongodb.

docker start MongoDB
Copy the code

Deploy RocketChat

Use the following command to deploy the image, and try several times if the download is slow or times out.

Docker run \ -itd \ -e PGID=1000 \ -e PUID=1000 \ --name=RocketChat \ --net=mynet \ -- IP =172.18.0.3 \ -e TZ = Asia/Shanghai \ - e MONGO_URL = mongo: / / rocketchat: [email protected]:27017 / rocketchat \ - e MONGO_OPLOG_URL = mongo: / / rocketchat: [email protected]:27017 / local? authSource=admin \ -p 3000:3000/tcp \ -v /opt/docker/rocketchat:/app/uploads:rw library/rocket.chatCopy the code

Disable the firewall, or enable port 3000TCP, and use the web page. The IP address is IP:3000(if you are a public network server, please use your public IP address). Configure the basic information and continue until the configuration is complete. Finally you can play happily, send an expression to try ~

conclusion

After the installation is successful, you can use SSL certificate to encrypt the site, which can be more secure. The HTTP protocol is not connected when a client connects to a private server.If you have problems with the installation and cannot continue, you can contact me for help (shell one-key script can be provided). If you need the client of each platform, you can also send me a private message