Even though I am a Rocket.Chat user myself, before I settled on it I looked into other collaboration platforms that are self-hosted and open source. In this short article, I would like to focus on Mattermost.
I won't spend too much time talking about the platform itself, but rather just give you steps on how to run it inside Docker using your favorite database platform of choice (this tutorial will focus on using PostgresDB). Let's see how to set it all up.
STEP01 - setting up the database (PostgresDB)
As with most chat platforms you will need to have some sort of database running and storing all the data. Mattermost (MM further in the text) can use MySQL or Postgres as its backed platform. I will use PostgresDB.
To get Postgres running, in case you already don't have it, you can use steps from my previous article here, specifically title named PostgreSQL container to get you started. After you have set up your PostgresDB and configured your database it is time to configure MM in its container.
STEP02 - setup MM Docker container
There are multiple Docker repos for MM and I will be using the free version called mattermost/mattermost-team-edition. As you can see from the repo description there is not much to go on, so be sure to consult this wiki site for more details on MM and Docker setup should you need it.
After you have downloaded your repo it is time to configure it:
docker run \
--name=mattermost \
-p 8065:8065
-p 8067:8067
-p 8074:8074
-p 8075:8075
-v /volume1/docker/mattermost/config:/mattermost/config
-v /volume1/docker/mattermost/client_plugins:/mattermost/client_plugins
-v /volume1/docker/mattermost/plugins:/mattermost/plugins
-v /volume1/docker/mattermost/logs:/mattermost/logs
-v /volume1/docker/mattermost/data:/mattermost/data
-e MM_SERVICESETTINGS_SITEURL=https://mmsite.yourdomain.something
-e MM_SQLSETTINGS_DATASOURCE=postgres://username:pass@NASIPADDRESS:5432/mattermost_databasename?sslmode=disable&connect_timeout=10
-e MM_SQLSETTINGS_DRIVERNAME=postgres
-e DB_HOST=your DB IP address
-e DB_PORT_NUMBER=5432
-e MM_DBNAME=MM database name
-e MM_PASSWORD=MM DB password
-e MM_USERNAME=MM DB username
mattermost/mattermost-team-edition
Few notes about some of the variables.
MM_SQLSETTINGS_DATASOURCE can work for both MySQL and Postgres DB. There are examples of how to run it with both.
MySQL connection string example:
mmuser:mmuser_password@unix(/run/mysqld/mysqld.sock)/mattermostdb?charset=utf8mb4,utf8.
PostgresDB connection string example:
postgres://mmuser:[email protected]:5432/mattermostdb?sslmode=disable&connect_timeout=10
Depending on what database platform you are using, you will need to adjust the MM_SQLSETTINGS_DRIVERNAMEvariable as well with MySQL or Postgres.
STEP03 - running MM behind a reverse proxy (Synology Application portal)
NOTE: This will only be important if you want to run this service outside your LAN and for production usage
Once you have it all set up and the container is up and running we need to do one final configuration to complete the setup. If you look at the docker run command above you will notice that there is an MM_SERVICESETTINGS_SITEURL variable set that should point to your HTTPS URL for your MM instance.
In order to get this up and running, you will need to register your domain and get a valid SSL certificate for it. You can check my previous articles on the matter of getting a valid SSL certificate here, as well as setting up any Docker hosted service using a reverse proxy here.
So, the final step is to configure your MM instance to respond to an https URL that will match the one that you have configured in your variable.
Keep in mind that if you do decide to run this service behind a reverse proxy you will need to configure WebSocket (Upgrade and Connection) parameters in your reverse proxy configuration for MM. If you are using the Synology Application portal (reverse proxy) feature you can do that using the user interface.
Now you are ready to access your MM instance using your browser and the URL that you have configured.
If you have any questions or comments, please share it down in the comment section or use the live chat feature in the bottom right corner of this (or any other ) article.