2024年4月27日

HYEOS

随事而为

Docker Install RocketChat

2 min read

您可能不希望使用标准的Docker命令,而是希望对部署进行更多的自动化管理。这就是使用Docker-compose可能会派上用场的地方。

确保您已安装Docker和Docker-compose并且可以正常运行。
docker-compose.yml根据我们的示例创建。这是您唯一需要的文件。您可以通过复制并粘贴内容在自己的计算机上创建此文件。
编辑image: rocketchat/rocket.chat:develop以指定要使用的映像(请参阅可用的Docker映像部分)
编辑ROOT_URL以匹配您的域名或IP地址

您可以下载我们的docker-compose.yaml:

curl -L https://raw.githubusercontent.com/RocketChat/Rocket.Chat/develop/docker-compose.yml -o docker-compose.yml

version: '2'

services:
rocketchat:
image: rocketchat/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
- 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: 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: 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

# hubot, the popular chatbot (add the bot user first and change the password before starting
this image)
hubot:
image: rocketchat/hubot-rocketchat:latest
restart: unless-stopped
environment:
- ROCKETCHAT_URL=rocketchat:3000
- ROCKETCHAT_ROOM=GENERAL
- ROCKETCHAT_USER=Hubot
- ROCKETCHAT_PASSWORD=botpassword
- BOT_NAME=Hubot
# you can add more scripts as you'd like here, they need to be installable by npm
- EXTERNAL_SCRIPTS=hubot-help,hubot-seen,hubot-links,hubot-diagnostics
depends_on:
- rocketchat
labels:
- "traefik.enable=false"
volumes:
- ./scripts:/home/hubot/scripts
# this is used to expose the hubot port for notifications on the host on port 3001, e.g. for
hubot-jenkins-notifier
ports:
- 3001:8080

#traefik:
# image: traefik:latest
# restart: unless-stopped
# command: >
# traefik
# --docker
# --acme=true
# --acme.domains='your.domain.tld'
# --acme.email='your@email.tld'
# --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

通过以下方式启动mongodb服务器:

docker-compose up -d mongo

第一次启动mongo时,还需要将其初始化才能使用Rocket.Chat。确保mongo处于运行状态,然后:

docker-compose up -d mongo-init-replica

Mongo支持24 x 7操作和实时备份。您不需要太频繁地重新启动它。有关mongo服务器的正确操作和管理,请参阅 mongodb文档。

一旦确定mongodb已启动并正在运行:

docker-compose up -d rocketchat

(可选)如果要管理消息和配置信息,请再次编辑该文件以取消注释卷安装。确保您有一个data子目录来装载和存储数据。

(可选)如果您想要一个机器人,那么在创建管理员用户和机器人用户之后,也不必跟自己说话,请docker-compose.yml再次编辑文件以更改变量,ROCKETCHAT_USER然后ROCKETCHAT_PASSWORD在hubot部分中启动,哈伯特:

docker-compose up -d hubot

要将rocketchatdocker映像更新为最新版本,可以使用以下命令。您的数据不应该受到此影响,因为它位于mongo图像中。

docker pull rocketchat/rocket.chat:develop
docker-compose stop rocketchat
docker-compose rm rocketchat
docker-compose up -d rocketchat

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注