GithubHelp home page GithubHelp logo

kant / mattermost-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ideo/mattermost-docker

0.0 1.0 0.0 168 KB

Dockerfile for mattermost in production

License: Apache License 2.0

Shell 100.00%

mattermost-docker's Introduction

Production Docker deployment for Mattermost

This project enables deployment of a Mattermost server in a multi-node production configuration using Docker.

Build Status

Notes:

Installation using Docker Compose

The following instructions deploy Mattermost in a production configuration using multi-node Docker Compose set up.

Requirements

Choose Edition to Install

If you want to install Enterprise Edition, you can skip this section.

To install the team edition, comment out the two following lines in docker-compose.yaml file:

args:
  - edition=team

The app Dockerfile will read the edition build argument to install Team (edition = 'team') or Entreprise (edition != team) edition.

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

It is possible to use your own PostgreSQL database, or even use MySQL. But you will need to ensure that Application container can connect to the database (see Application container)

AWS

If deploying to AWS, you could also set following variables to enable 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

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:

# 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.

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

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

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.

If you choose to use MySQL instead of PostgreSQL, you should set a different datasource and SQL driver :

  • DB_PORT_NUMBER : 3306
  • MM_SQLSETTINGS_DRIVERNAME : mysql
  • MM_SQLSETTINGS_DATASOURCE : MM_USERNAME:MM_PASSWORD@tcp(DB_HOST:DB_PORT_NUMBER)/MM_DBNAME?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s" Don't forget to replace all entries (beginning by MM_ and DB_) in MM_SQLSETTINGS_DATASOURCE with the real variables values.

Web server container

This image is optional, you should not use it when you have your own reverse-proxy. It is a simple front Web server for the Mattermost app container. If you use the provided docker-compose.yml file, you don't have to configure anything. But if your application container is reachable on custom host and/or port (eg. if you use a container provider), you should add those two environment variables :

  • APP_HOST: application host address
  • APP_PORT_NUMBER: application HTTP port

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.

Starting/Stopping Docker

Start

docker-compose start

Stop

docker-compose stop

Removing Docker

Remove the containers

docker-compose stop && docker-compose rm

Remove the data and settings of your Mattermost instance

sudo rm -rf volumes

Update Mattermost to latest version

First, shutdown your containers to back up your data.

docker-compose down

Back up your mounted volumes to save your data. If you use the default docker-compose.yml file proposed on this repository, your data is on ./volumes/ folder.

Then run the following commands.

git pull
docker-compose build
docker-compose up -d

Your Docker image should now be on the latest Mattermost version.

Upgrading to Team Edition 3.0.x from 2.x

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.

docker-compose rm -f app
docker-compose build app
docker-compose run app -upgrade_db_30
docker-compose up -d

See the offical Upgrade Guide for more details.

Installation using Docker Swarm Mode

The following instructions deploy Mattermost in a production configuration using docker swarm mode on one node. Running containerized applications on multi-node swarms involves specific data portability and replication handling that are not covered here.

Requirements

Swarm Mode Installation

First, create mattermost directory structure on the docker hosts:

mkdir -p /var/lib/mattermost/{cert,config,data,logs}

Then, fire up the stack in your swarm:

docker stack deploy -c contrib/swarm/docker-stack.yml mattermost

Known Issues

  • Do not modify the Listen Address in Service Settings.
  • Rarely app container fails to start because of "connection refused" to database. Workaround: Restart the container.

More information

If you want to know how to use docker-compose, see the overview page.

For the server configurations, see prod-ubuntu.rst of Mattermost.

mattermost-docker's People

Contributors

carlosasj avatar codecraf8 avatar darkrasid avatar em-ak avatar eungjun-yi avatar fingerliu avatar fmaker avatar it33 avatar jasonblais avatar jminardi avatar jnbt avatar lfbrock avatar localsnet avatar mkdbns avatar nikosch86 avatar pdemagny avatar pichouk avatar pierreozoux avatar quentinus95 avatar rothgar avatar samer avatar sebgl avatar tejasbubane avatar timrsmith avatar tivvit avatar xcompass avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.