Mattermost docker環境安裝筆記
參考: https://docs.mattermost.com/install/install-docker.html
1. 登入DSM或以SSH登入NAS,這裡以SSH方式為主,輸入
# 切至docker根目錄
cd /volume1/docker1
# 拉取mattermost專案倉庫
git clone https://github.com/mattermost/docker mattermost
cd mattermost
2. 配置設定檔
cp env.example .env
nano .env
# At a minimum, you must edit the DOMAIN value in the .env file to correspond to the domain for your Mattermost server.
這是我的配置檔,供參考~
# Domain of service
DOMAIN=im.techeasy.org
# Container settings
## Timezone inside the containers. The value needs to be in the form 'Europe/Berlin'.
## A list of these tz database names can be looked up at Wikipedia
## https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TZ=Asia/Taipei
RESTART_POLICY=unless-stopped
# Postgres settings
## Documentation for this image and available settings can be found on hub.docker.com
## https://hub.docker.com/_/postgres
## Please keep in mind this will create a superuser and it's recommended to use a less privileged
## user to connect to the database.
## A guide on how to change the database user to a nonsuperuser can be found in docs/creation-of-nonsuperuser.md
POSTGRES_IMAGE_TAG=13-alpine
POSTGRES_DATA_PATH=./volumes/db/var/lib/postgresql/data
POSTGRES_USER=帳號
POSTGRES_PASSWORD=密碼
POSTGRES_DB=mattermost
# Nginx
## The nginx container will use a configuration found at the NGINX_MATTERMOST_CONFIG. The config aims
## to be secure and uses a catch-all server vhost which will work out-of-the-box. For additional settings
## or changes ones can edit it or provide another config. Important note: inside the container, nginx sources
## every config file inside */etc/nginx/conf.d* ending with a *.conf* file extension.
## Inside the container the uid and gid is 101. The folder owner can be set with
## `sudo chown -R 101:101 ./nginx` if needed.
NGINX_IMAGE_TAG=alpine
## The folder containing server blocks and any additional config to nginx.conf
NGINX_CONFIG_PATH=./nginx/conf.d
NGINX_DHPARAMS_FILE=./nginx/dhparams4096.pem
CERT_PATH=./volumes/web/cert/cert.pem
KEY_PATH=./volumes/web/cert/key-no-password.pem
#GITLAB_PKI_CHAIN_PATH=<path_to_your_gitlab_pki>/pki_chain.pem
#CERT_PATH=./certs/etc/letsencrypt/live/${DOMAIN}/fullchain.pem
#KEY_PATH=./certs/etc/letsencrypt/live/${DOMAIN}/privkey.pem
## Exposed ports to the host. Inside the container 80 and 443 will be used
HTTPS_PORT=443
HTTP_PORT=80
# Mattermost settings
## Inside the container the uid and gid is 2000. The folder owner can be set with
## `sudo chown -R 2000:2000 ./volumes/app/mattermost`.
MATTERMOST_CONFIG_PATH=./volumes/app/mattermost/config
MATTERMOST_DATA_PATH=./volumes/app/mattermost/data
MATTERMOST_LOGS_PATH=./volumes/app/mattermost/logs
MATTERMOST_PLUGINS_PATH=./volumes/app/mattermost/plugins
MATTERMOST_CLIENT_PLUGINS_PATH=./volumes/app/mattermost/client/plugins
MATTERMOST_BLEVE_INDEXES_PATH=./volumes/app/mattermost/bleve-indexes
## Bleve index (inside the container)
MM_BLEVESETTINGS_INDEXDIR=/mattermost/bleve-indexes
## This will be 'mattermost-enterprise-edition' or 'mattermost-team-edition' based on the version of
Mattermost you're installing.
##務必指定team-edition,這才是免費使用版本,另外目前版本最新是7.9
MATTERMOST_IMAGE=mattermost-team-edition
MATTERMOST_IMAGE_TAG=release-7.9
## Make Mattermost container readonly. This interferes with the regeneration of root.html inside the container. Only use
## it if you know what you're doing.
## See https://github.com/mattermost/docker/issues/18
MATTERMOST_CONTAINER_READONLY=false
## The app port is only relevant for using Mattermost without the nginx container as reverse proxy. This is not meant
## to be used with the internal HTTP server exposed but rather in case one wants to host several services on one host
## or for using it behind another existing reverse proxy.
APP_PORT=8065
## Configuration settings for Mattermost. Documentation on the variables and the settings itself can be found at
## https://docs.mattermost.com/administration/config-settings.html
## Keep in mind that variables set here will take precedence over the same setting in config.json. This includes
## the system console as well and settings set with env variables will be greyed out.
## Below one can find necessary settings to spin up the Mattermost container
MM_SQLSETTINGS_DRIVERNAME=postgres
MM_SQLSETTINGS_DATASOURCE=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&connect_timeout=10
## Example settings (any additional setting added here also needs to be introduced in the docker-compose.yml)
MM_SERVICESETTINGS_SITEURL=http://${DOMAIN}
3. 創建app所需用到的資料夾並賦予所需權限
mkdir -p ./volumes/app/mattermost/{config,data,logs,plugins,client/plugins,bleve-indexes}
sudo chown -R 2000:2000 ./volumes/app/mattermost
4. 我的NAS已經有反向代理功能,故官方這段設定nginx的段落直接忽略
5. 安裝docker
這段視nas硬體能力耗費時間不等
sudo docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d
#安裝若順利會出現類似下方資訊
Creating network "mattermost_default" with the default driver
Pulling mattermost (mattermost/mattermost-enterprise-edition:7.1)...
7.1: Pulling from mattermost/mattermost-enterprise-edition
751ef25978b2: Pull complete
6058830c33a8: Pull complete
f9580aa23981: Pull complete
c7989beb8f48: Pull complete
Digest: sha256:2fe9f455549a489a9007bff0a6da89fca4551ca6565844a6744a2c353e0a0554
Status: Downloaded newer image for mattermost/mattermost-enterprise-edition:7.1
Creating mattermost_postgres_1 ... done
Creating mattermost_mattermost_1 ... done
確認docker都處於運行狀態而不是不斷重開機,基本上就是完成了
6. 初次登入
預設的PORT為tcp 8065,可以同時先去設定反向代理
![image-20220921041029734](Mattermost docker環境安裝筆記.assets/image-20220921041029734.png)
登入網址是http://區網IP:8065 或反向代理後的url,初次登入第一件事就是建立管理帳號,安裝到此為止!
![image-20220921041756429](Mattermost docker環境安裝筆記.assets/image-20220921041756429.png)
6-1 啟用搜尋
mattermost預設沒啟用搜尋,這樣當訊息量一多想回頭找紀錄非常的麻煩,所以強力建議啟用,參考官方教學,在管理面板設定Bleve區塊
Follow these steps to configure the Mattermost server to use Bleve and generate required indexes. Once the configuration is saved, new posts made to the database will be automatically indexed with Bleve.
Note: During indexing, search results may be incomplete until the indexing job is complete.
- Open System Console > Experimental > Bleve.
- Set Enable Bleve Indexing to true to enable the other settings on the page.
- Set the directory path to use for storing Bleve indexes (e.g.:
/var/opt/mattermost/bleveindexes
). The user running Mattermost should have permissions to access the directory. See our Configuration Settings documentation for details.
- Save the configuration.
- Select Index Now. All users, channels, and posts in the database will be indexed oldest to newest.
- Set Enable Bleve for search queries to true.
- Set Enable Bleve for autocomplete queries to true.
7. 維護與更新
調整設定後重啟docker
sudo docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml restart
關閉刪除現有docker
sudo docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml down
拉取最新映像
sudo docker-compose -f docker-compose.yml pull
建置docker
sudo docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d
成果圖
後台
聊天室