Centos7 使用Docker安裝rocket.chat聊天工具
阿新 • • 發佈:2022-03-11
Centos7: 使用Docker安裝rocket.chat聊天工具
下載安裝
Rocket.Chat 目前最新的版本為 4.0.1,可以通過手動或者容器的方式安裝。這裡我推薦使用容器,部署過程會方便不少。
如果要用容器的方式部署,需要先安裝 docker 和 docker-compose,再下載編排檔案:
安裝docker指令碼
#!/bin/sh # # setenforce 0 sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config systemctl stop firewalld && systemctl disable firewalld swapoff -a && echo "swapoff -a" >> /etc/rc.local && chmod +x /etc/rc.local yum install -y wget vim lrzsz telnet net-tools yum install -y yum-utils device-mapper-persistent-data lvm2 yum install -y https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm mkdir -p /etc/docker cat > /etc/docker/daemon.json <<EOF { "registry-mirrors": ["https://q2uvt0x7.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=cgroupfs"], "data-root": "/data/docker", "storage-driver": "overlay2", "storage-opts":["overlay2.override_kernel_check=true"], "log-driver": "json-file", "log-opts": { "max-size": "100m", "max-file": "10" } } EOF systemctl enable docker && systemctl daemon-reload && systemctl start docker echo "* soft nofile 655360" >> /etc/security/limits.conf echo "* hard nofile 655360" >> /etc/security/limits.conf echo "* soft nproc 655360" >> /etc/security/limits.conf echo "* hard nproc 655360" >> /etc/security/limits.conf echo "* soft memlock unlimited" >> /etc/security/limits.conf echo "* hard memlock unlimited" >> /etc/security/limits.conf echo "DefaultLimitNOFILE=1024000" >> /etc/systemd/system.conf echo "DefaultLimitNPROC=1024000" >> /etc/systemd/system.conf ulimit -Hn yum -y install chrony systemctl enable chronyd.service && systemctl start chronyd.service && systemctl status chronyd.service chronyc sources
安裝docker-compose
yum install epel-release -y
yum install docker-compose -y
# 建立並進入工作目錄
mkdir /opt/rocketchat
cd /opt/rocketchat
# 下載編排檔案
curl -L https://raw.githubusercontent.com/RocketChat/Rocket.Chat/develop/docker-compose.yml -o docker-compose.yml
若下載失敗,可使用下面檔案
version: '2' services: rocketchat: image: ccr.ccs.tencentyun.com/tcb-100024104308-urur/rocket.chat:latest command: > bash -c "for i in `seq 1 30`; do node main.js && s=$$? && break || s=$$?; echo \"Tried $$i times. Waiting 5 secs...\"; sleep 5; done; (exit $$s)" restart: unless-stopped volumes: - ./uploads:/app/uploads environment: - PORT=3000 - ROOT_URL=http://localhost:3000 - MONGO_URL=mongodb://mongo:27017/rocketchat - MONGO_OPLOG_URL=mongodb://mongo:27017/local - REG_TOKEN=${REG_TOKEN} # - MAIL_URL=smtp://smtp.email # - HTTP_PROXY=http://proxy.domain.com # - HTTPS_PROXY=http://proxy.domain.com depends_on: - mongo ports: - 3000:3000 labels: - "traefik.backend=rocketchat" - "traefik.frontend.rule=Host: your.domain.tld" mongo: image: ccr.ccs.tencentyun.com/tcb-100024104308-urur/mongo:4.0 restart: unless-stopped volumes: - ./data/db:/data/db #- ./data/dump:/dump command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1 labels: - "traefik.enable=false" # this container's job is just run the command to initialize the replica set. # it will run the command and remove himself (it will not stay running) mongo-init-replica: image: ccr.ccs.tencentyun.com/tcb-100024104308-urur/mongo:4.0 command: > bash -c "for i in `seq 1 30`; do mongo mongo/rocketchat --eval \" rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: 'localhost:27017' } ]})\" && s=$$? && break || s=$$?; echo \"Tried $$i times. Waiting 5 secs...\"; sleep 5; done; (exit $$s)" depends_on: - mongo #traefik: # image: traefik:latest # restart: unless-stopped # command: > # traefik # --docker # --acme=true # --acme.domains='your.domain.tld' # --acme.email='[email protected]' # --acme.entrypoint=https # --acme.storagefile=acme.json # --defaultentrypoints=http # --defaultentrypoints=https # --entryPoints='Name:http Address::80 Redirect.EntryPoint:https' # --entryPoints='Name:https Address::443 TLS.Certificates:' # ports: # - 80:80 # - 443:443 # volumes: # - /var/run/docker.sock:/var/run/docker.sock
根據自己的需求來修改編排檔案,修改完成後,執行以下命令啟動服務:
docker-compose up -d
服務啟動後,在瀏覽器中輸入 http://{ip}:3000
進行訪問。
使用說明
第一次使用 Rocket.Chat 時,一些可能會不太習慣。不過不用擔心,Rocket.Chat 用起來還是比較簡單的。接下來,我會向大家演示 Rocket.Chat 的基本用法。
安裝嚮導
我們第一次訪問 Rocket.Chat 時,會被引導到安裝嚮導,根據頁面的提示來配置就好。