2017-02-04 07:07:23 +01:00
# Production Docker deployment for Mattermost
2015-11-30 07:09:07 +01:00
2017-02-23 22:32:24 +01:00
This project enables deployment of a Mattermost server in a multi-node production configuration using Docker.
2016-04-12 07:09:03 +02:00
2016-04-24 17:44:04 +02:00
[![Build Status ](https://travis-ci.org/mattermost/mattermost-docker.svg?branch=master )](https://travis-ci.org/mattermost/mattermost-docker)
2017-02-23 22:32:24 +01:00
Notes:
2017-07-16 12:33:41 +02:00
- The default Mattermost edition for this repo has changed from Team Edition to Enterprise Edition. Please see [Choose Edition ](#choose-edition-to-install ) section.
- To install this Docker project on AWS Elastic Beanstalk please see [AWS Elastic Beanstalk Guide ](contrib/aws/README.md ).
2017-06-02 23:56:51 +02:00
- To run Mattermost on Kubernetes you can start with the [manifest examples in the kubernetes folder ](contrib/kubernetes/README.md )
2017-02-04 07:07:23 +01:00
- To install Mattermost without Docker directly onto a Linux-based operating systems, please see [Admin Guide ](https://docs.mattermost.com/guides/administrator.html#installing-mattermost ).
2015-11-30 07:09:07 +01:00
2017-02-23 22:32:24 +01:00
## Installation using Docker Compose
2017-02-04 07:07:23 +01:00
2017-02-23 22:32:24 +01:00
The following instructions deploy Mattermost in a production configuration using multi-node Docker Compose set up.
2015-11-30 07:09:07 +01:00
2017-02-04 07:07:23 +01:00
### Requirements
2015-11-30 07:09:07 +01:00
2017-02-04 07:07:23 +01:00
* [docker]
* [docker-compose]
2017-01-31 01:51:36 +01:00
2017-03-13 23:26:45 +01:00
### Choose Edition to Install
2017-07-16 12:33:41 +02:00
If you want to install Enterprise Edition, you can skip this section.
2017-03-13 23:26:45 +01:00
2017-07-16 12:33:41 +02:00
To install the Team Edition, comment out the following line in docker-compose.yaml file:
2017-06-02 23:56:51 +02:00
```
dockerfile: Dockerfile-enterprise
```
2017-03-13 23:26:45 +01:00
2017-07-16 12:33:41 +02:00
### Database container
This repository offer a Docker image for the Mattermost database. It is a customized PostgreSQL image that you should configure with following environment variables :
* `POSTGRES_USER` : database username
* `POSTGRES_PASSWORD` : database password
* `POSTGRES_DB` : database name
2017-02-23 22:32:24 +01:00
2017-07-16 12:33:41 +02:00
#### AWS
If deploying to AWS, you could also set following variables to enable [Wal-E ](https://github.com/wal-e/wal-e ) backup to S3 :
* `AWS_ACCESS_KEY_ID` : AWS access key
* `AWS_SECRET_ACCESS_KEY` : AWS secret
* `WALE_S3_PREFIX` : AWS s3 bucket name
* `AWS_REGION` : AWS region
2017-02-23 22:32:24 +01:00
2017-07-16 12:33:41 +02:00
All four environment variables are required. It will enable completed WAL segments sent to archive storage (S3). The base backup and clean up can be done through the following command:
```bash
# Base backup
docker exec mattermost-db su - postgres sh -c "/usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e backup-push /var/lib/postgresql/data"
# Keep the most recent 7 base backups and remove the old ones
docker exec mattermost-db su - postgres sh -c "/usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e delete --confirm retain 7"
```
Those tasks can be executed through a cron job or systemd timer.
2015-11-30 07:09:07 +01:00
2017-07-16 12:33:41 +02:00
### Application container
Application container run the Mattermost application. You should configure it with following environment variables :
* `MM_USERNAME` : database username
* `MM_PASSWORD` : database password
* `MM_DBNAME` : database name
2015-11-30 07:09:07 +01:00
2017-07-16 12:33:41 +02:00
If your database use some custom host and port, it is also possible to configure them :
* `DB_HOST` : database host address
* `DB_PORT_NUMBER` : database port
2016-04-07 10:34:10 +02:00
2017-07-16 12:33:41 +02:00
If you use a Mattermost configuration file on a different location than the default one (`/mattermost/config/config.json`) :
* `MM_CONFIG` : configuration file location inside the container.
2016-04-07 10:34:10 +02:00
2017-07-16 12:33:41 +02:00
If you choose to use MySQL instead of PostgreSQL, you should set a different datasource :
2017-07-16 12:38:23 +02:00
* `MM_SQLSETTINGS_DATASOURCE` : `"$MM_USERNAME:$MM_PASSWORD@tcp($DB_HOST:$DB_PORT_NUMBER)/$MM_DBNAME?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s"`
2016-04-07 10:34:10 +02:00
2017-07-16 12:33:41 +02:00
### Web server container
This image is optional, you should not use it you have your own reverse-proxy. It is a simple front Web server for the Mattermost app container.
* `MATTERMOST_ENABLE_SSL` : whether to enable SSL
* `PLATFORM_PORT_80_TCP_PORT` : port that Mattermost image is listening on
2016-04-07 10:34:10 +02:00
2017-07-16 12:33:41 +02:00
#### Install with SSL certificate
Put your SSL certificate as `./volumes/web/cert/cert.pem` and the private key that has
no password as `./volumes/web/cert/key-no-password.pem` . If you don't have
them you may generate a self-signed SSL certificate.
2016-04-07 10:34:10 +02:00
## Starting/Stopping
### Start
2017-06-02 23:56:51 +02:00
```
docker-compose start
```
2015-11-30 07:09:07 +01:00
### Stop
2017-06-02 23:56:51 +02:00
```
docker-compose stop
```
2016-04-07 10:34:10 +02:00
2017-03-03 17:16:47 +01:00
### Update
Make sure to backup Mattermost data before proceeding.
2017-06-02 23:56:51 +02:00
```
docker-compose down
git pull
docker-compose build
docker-compose up -d
```
2017-03-03 17:16:47 +01:00
2016-04-07 10:34:10 +02:00
## Removing
2015-11-30 07:09:07 +01:00
2015-12-04 10:19:06 +01:00
### Remove the containers
2017-06-02 23:56:51 +02:00
```
docker-compose stop & & docker-compose rm
```
2015-11-30 07:09:07 +01:00
2017-07-16 12:33:41 +02:00
### Remove the data and settings of your Mattermost instance
2017-06-02 23:56:51 +02:00
```
sudo rm -rf volumes
```
2015-12-04 10:19:06 +01:00
2016-05-17 14:20:41 +02:00
## Upgrading to Team Edition 3.0.x from 2.x
2017-07-16 12:33:41 +02:00
You need to migrate your database before upgrading Mattermost to `3.0.x` from
`2.x` . Run these commands in the latest `mattermost-docker` directory.
2017-06-02 23:56:51 +02:00
```
docker-compose rm -f app
docker-compose build app
docker-compose run app -upgrade_db_30
docker-compose up -d
```
2016-05-17 14:20:41 +02:00
See the [offical Upgrade Guide ](http://docs.mattermost.com/administration/upgrade.html ) for more details.
2015-12-03 16:40:11 +01:00
## Known Issues
* Do not modify the Listen Address in Service Settings.
2017-07-16 12:33:41 +02:00
* Rarely `app` container fails to start because of "connection refused" to
2015-12-04 10:20:00 +01:00
database. Workaround: Restart the container.
2015-12-03 16:40:11 +01:00
2017-02-04 07:07:23 +01:00
## More information
2015-11-30 07:09:07 +01:00
If you want to know how to use docker-compose, see [the overview
page](https://docs.docker.com/compose).
2017-07-16 12:33:41 +02:00
For the server configurations, see [prod-ubuntu.rst] of Mattermost.
2015-11-30 07:09:07 +01:00
[docker]: http://docs.docker.com/engine/installation/
[docker-compose]: https://docs.docker.com/compose/install/
2017-01-27 15:25:58 +01:00
[prod-ubuntu.rst]: https://docs.mattermost.com/install/install-ubuntu-1404.html