diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ec5f12ab734c47d3ec306ed85418aaa002a077dd..b70757eae2c61bf9481e8b6acc0768826dbf808a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,6 +37,16 @@ package:apt:bullseye: needs: - build:binary:bullseye +# for now, publish the bullseye package for buster as well +publish:apt:buster: + extends: .publish:apt + variables: + APTLY_DISTRO: buster + dependencies: + - package:apt:bullseye + needs: + - package:apt:bullseye + publish:apt:bullseye: extends: .publish:apt variables: diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ba719856f932d6bdcfa58fc68e5e4fea216fad14 --- /dev/null +++ b/README.md @@ -0,0 +1,122 @@ +Third-party RocketChat Package for Debian +========================================= + +RocketChat is a web-based chat platform. See https://rocket.chat/ for details. + +This is a package for deploying RocketChat on Debian Buster or Bullseye. + +**Disclaimer:** This package is provided by a third party. It is **not** an +official package from the RocketChat project or the Debian project. It is +automatically built from upstream releases without any review or testing. +The package does not fully adhere to Debian packaging standards (especially +regarding the vendoring of dependencies). + +Prerequisite: Node.js 12 +------------------------ + +**This only applies to Debian Buster.** The Node.js version in Debian +Bullseye is new enough. + +RocketChat requires at least version 12 of Node.js. The package in the official +Debian repositories for Debian Buster is too old. + +Enable nodesource.com Debian repo: + +```sh +wget -q https://deb.nodesource.com/gpgkey/nodesource.gpg.key -O /etc/apt/trusted.gpg.d/nodesource.asc +echo "deb https://deb.nodesource.com/node_12.x buster main" > /etc/apt/sources.list.d/nodesource.list +apt update +``` + +Installing the RocketChat package later automatically installs Node.js as a +dependency. + +Prerequisite: MongoDB +--------------------- + +MongoDB is not available in the official Debian repositories. However, the +MongoDB project provides a third-party repo for Debian. + +MongoDB can be installed on the same system as RocketChat or on a separate +system. The default config in the RocketChat package expects a local +installation of MongoDB. + +Enable the mongodb.org Debian repo, install the `mongodb-org` package, enable +and start the `mongod` service: + +```sh +wget https://www.mongodb.org/static/pgp/server-4.2.asc -O /etc/apt/trusted.gpg.d/mongodb.asc +echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" > /etc/apt/sources.list.d/mongodb.list +apt update +apt install mongodb-org +systemctl enable mongod +systemctl start mongod +``` + +Note: At the time of writing there is no repo for Debian Bullseye on +repo.mongodb.org. The Debian Buster repo seems to work fine on Bullseye. + +RocketChat requires [setting up a replica set](https://docs.rocket.chat/quick-start/installing-and-updating/manual-installation/mongo-replicas). +Configure the replica set, start MongoDB and initialize the replica set: + +```sh +printf 'replication:\n replSetName: "rs01"\n' >> /etc/mongod.conf +systemctl start mongod +mongo --eval 'rs.initiate()' +``` + +If you install MongoDB on the same host as RocketChat, the corresponding +MongoDB URL is `mongodb://localhost:27017/rocketchat?replicaSet=rs01` and +the oplog URL is `mongodb://localhost:27017/local?replicaSet=rs01`. These +are the default values, so you don't need to change the RocketChat config +in `/etc/rocketchat.conf`. + +Install and Setup RocketChat +---------------------------- + +Enable the `infrapackages-rocketchat` repo on https://packages.cccv.de/, +then install the package `rocketchat`: + +```sh +wget https://packages.cccv.de/docs/cccv-archive-key.gpg -O /etc/apt/trusted.gpg.d/cccv-archive.asc +echo "deb https://packages.cccv.de/infrapackages-rocketchat bullseye main" > /etc/apt/sources.list.d/cccv-rocketchat.list +apt update +apt install rocketchat +``` + +Customize the configuration in `/etc/rocketchat.conf` and restart RocketChat +with `systemctl restart rocketchat`. + +Per default RocketChat listens on `http://localhost:3000/`. Open +`http://localhost:3000/` in a webbrowser and follow the setup instructions. + +Setup Follower Instances +------------------------ + +Node.js applications are single-threaded. If you have more than a single CPU +core, you will want to run [additional RocketChat instances ("followers") on +the same host](https://docs.rocket.chat/quick-start/installing-and-updating/manual-installation/multiple-instances-to-improve-performance) +to improve performance. + +The package includes the systemd service template `rocketchat-follower@`. The +instance name is used as the IP the RocketChat follower instance binds to. + +Note that the official guide uses different ports for follower instances +instead of different IPs. We found that with enabled Prometheus metrics, +follower instances fail to start as they attempt to bind the same metrics +port as the main instance. + +Follower instances use the same config options as the main instance +(`/etc/rocketchat.conf`). Options can be overwritten for followers in +`/etc/rocketchat-follower.conf` + +To enable one follower (e.g. on a system with two CPUs) run: + +```sh +systemctl enable rocketchat-follower@127.0.0.2 +systemctl restart rocketchat +``` + +Afterwards the two instances will listen on `http://127.0.0.1:3000/` and +`http://127.0.0.1:3001/`. Setup a load-balancer to use both instances as +upstreams. diff --git a/debian/install b/debian/install index 146373aff6fdcbb9462c66eebd1d7323d259e919..fb844d6712e73d82c2befdc81df1339cc0e194cb 100644 --- a/debian/install +++ b/debian/install @@ -1,3 +1,6 @@ build/bundle /usr/share/rocketchat rocketchat.service /lib/systemd/system/ +rocketchat-follower@.service /lib/systemd/system/ rocketchat.conf /etc/ +rocketchat-follower.conf /etc/ +README.md /usr/share/doc/wekan/ diff --git a/rocketchat-follower.conf b/rocketchat-follower.conf new file mode 100644 index 0000000000000000000000000000000000000000..550a11a8ad04f1c0012ec42f3b1914421208cc77 --- /dev/null +++ b/rocketchat-follower.conf @@ -0,0 +1,9 @@ +# Both the main rocketchat service and the rocketchat-follower@ services use +# the config options from "/etc/rocketchat.conf". Use this file to overwrite +# options for the rocketchat-follower@ services. + +# Note that for followers BIND_IP is automatically set to the instance name. +# E.g. for rocketchat-follower@127.0.0.2.service BIND_IP is set to 127.0.0.2, +# so the service binds to 127.0.0.2. + +DISABLE_PRESENCE_MONITOR=YES diff --git a/rocketchat-follower@.service b/rocketchat-follower@.service index ddeb641887f52ca000940eaad86bd8b1033f4f28..11d548f5bc447223563e0b07c62c397b49664bd8 100644 --- a/rocketchat-follower@.service +++ b/rocketchat-follower@.service @@ -3,20 +3,20 @@ Description=RocketChat Server (follower, depending on main service) After=network.target Wants=network-online.target Wants=systemd-networkd-wait-online.service +PartOf=rocketchat.service [Service] -ExecStart=/usr/bin/node /usr/share/rocketchat/bundle/main.js +# Overwrite BIND_IP from config files with instance name. We cannot use +# Environment for this, since EnvironmentFile takes precedence over it. +ExecStart=env BIND_IP=%I /usr/bin/node /usr/share/rocketchat/bundle/main.js Restart=on-failure RestartSec=10 ExecReload=/bin/kill -USR1 $MAINPID -StandardOutput=syslog -StandardError=syslog SyslogIdentifier=rocketchat -EnvironmentFile=/etc/rocketchat.conf Environment=NODE_ENV=production -Environment=DISABLE_PRESENCE_MONITOR=YES -Environment=PORT=%I +EnvironmentFile=/etc/rocketchat.conf +EnvironmentFile=/etc/rocketchat-follower.conf DynamicUser=true PrivateUsers=true @@ -43,4 +43,4 @@ SystemCallArchitectures=native SystemCallFilter=@system-service [Install] -WantedBy=multi-user.target +WantedBy=rocketchat.service diff --git a/rocketchat.conf b/rocketchat.conf index ed2fb3ef99ac494b44c7c6cc6a0961d7f8d7947a..33cc5ba7310f20a59ba0bec6fce96399f211f984 100644 --- a/rocketchat.conf +++ b/rocketchat.conf @@ -1,8 +1,11 @@ +# BIND_IP only applies to the main instance. Follower instances +# (rocketchat-follower@ services) use the instance name as their BIND_IP. BIND_IP=127.0.0.1 -# Overwritten with PORT for rocketchat-follower@<PORT> PORT=3000 ROOT_URL=http://localhost MONGO_URL="mongodb://localhost:27017/rocketchat?replicaSet=rs01" MONGO_OPLOG_URL="mongodb://localhost:27017/local?replicaSet=rs01" -# Overwritten with YES for rocketchat-follower@ DISABLE_PRESENCE_MONITOR=NO + +# Use /etc/rocketchat-follower.conf to overwrite options for +# rocketchat-follower@ services. diff --git a/rocketchat.service b/rocketchat.service index a687144c7e6d77775dab2a2666dcd32cd39e8ec3..8dd8fa09d990832b008aeea3197502ae5ac33557 100644 --- a/rocketchat.service +++ b/rocketchat.service @@ -9,12 +9,10 @@ ExecStart=/usr/bin/node /usr/share/rocketchat/bundle/main.js Restart=on-failure RestartSec=10 ExecReload=/bin/kill -USR1 $MAINPID -StandardOutput=syslog -StandardError=syslog SyslogIdentifier=rocketchat -EnvironmentFile=/etc/rocketchat.conf Environment=NODE_ENV=production +EnvironmentFile=/etc/rocketchat.conf DynamicUser=true PrivateUsers=true