Mattermost Logo
Edit on GitHub

Developer Setup

Set up your development environment for building, running, and testing the Mattermost server.

  1. Install and configure Docker CE: https://docs.docker.com/docker-for-mac/.

    Note: MM-9791 introduced using docker-compose to manage containers. To preserve your data on upgrade, execute the following steps.

    First, backup from any existing containers:

    mysqldump -h 127.0.0.1 --column-statistics=0 -u mmuser -p mattermost_test > mm_mysql_backup.sql
    pg_dump -U mmuser -W -d mattermost_test -h 127.0.0.1 > mm_postgres_backup.bak

    Then after upgrading and starting the new docker-compose managed containers, restore the data:

    mysql -u mmuser -p -h 127.0.0.1 mattermost_test < mm_mysql_backup.sql
    psql -U mmuser -W -h 127.0.0.1 -f mm_postgres_backup.bak mattermost_test

    If you don’t migrate your data, the new, docker-compose-managed containers will start out empty. To remove the old containers – destroying any existing data – use make clean-old-docker.

  2. Download and install homebrew: https://brew.sh/.

  3. Install Go:

    brew install go
  4. Update your shell’s initialization script (e.g. .bashrc or .zshrc) and add the following:

    export GOPATH=$HOME/go
    export PATH=$PATH:$GOPATH/bin
    ulimit -n 8096
  5. Re-source your shell’s initialization script to update GOPATH and PATH in your current shell:

    source $HOME/.bashrc
  6. Fork https://github.com/mattermost/mattermost-server

  7. Clone the Mattermost source code from your fork:

    git clone https://github.com/YOUR_GITHUB_USERNAME/mattermost-server.git
  8. Start the server:

    cd mattermost-server
    make run-server

    Note: If you see lot of nc: bad address 'elasticsearch' messages, eventually exiting with the message Service elasticsearch:9200 did not start within 300 seconds. Aborting..., increase the memory available for the Docker Engine by going to Docker’s preferences -> Advanced.

  9. Test your environment:

    curl http://localhost:8065/api/v4/system/ping
    make stop-server

    If successful, the curl step will return a JSON object:

    {"AndroidLatestVersion":"","AndroidMinVersion":"","DesktopLatestVersion":"","DesktopMinVersion":"","IosLatestVersion":"","IosMinVersion":"","status":"OK"}

    Note: Browsing directly to http://localhost:8065/ will display a 404 Not Found until the web app is configured. See Web App Developer Setup and Mobile App Developer Setup for additional setup.

    The stop-server make target does not stop all the docker containers started by run-server. To stop the running docker containers:

    make stop-docker
  1. Install and configure Docker CE:

    curl -fsSL https://get.docker.com -o get-docker.sh
    sudo sh get-docker.sh
    sudo usermod -aG docker $(whoami)
    docker login

    If you prefer to perform these steps manually:

    Note: MM-9791 introduced using docker-compose to manage containers. To preserve your data on upgrade, execute the following steps.

    First, backup from any existing containers:

    mysqldump -h 127.0.0.1 --column-statistics=0 -u mmuser -p mattermost_test > mm_mysql_backup.sql
    pg_dump -U mmuser -W -d mattermost_test -h 127.0.0.1 > mm_postgres_backup.bak

    Then after upgrading and starting the new docker-compose managed containers, restore the data:

    mysql -u mmuser -p -h 127.0.0.1 mattermost_test < mm_mysql_backup.sql
    psql -U mmuser -W -h 127.0.0.1 -f mm_postgres_backup.bak mattermost_test

    If you don’t migrate your data, the new, docker-compose-managed containers will start out empty. To remove the old containers – destroying any existing data – use make clean-old-docker.

  2. Install docker-compose

    sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
  3. Install Go (modify installation to latest Go version from https://golang.org/dl/):

    sudo apt-get install -y build-essential
    sudo rm -rf /usr/local/go
    wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz
    sudo tar -C /usr/local -xzf go1.13.3.linux-amd64.tar.gz
  4. Update your shell’s initialization script (e.g. .bashrc or .zshrc) and add the following:

    export GOPATH=$HOME/go
    export PATH=$PATH:$GOPATH/bin
    export PATH=$PATH:/usr/local/go/bin
  5. Edit /etc/security/limits.conf as an administrator (e.g. sudo) and add the following lines, replacing {username} with your username:

    {username}  soft  nofile  8096
    {username}  hard  nofile  8096
  6. Logout and login to effect the changes above.

  7. Fork https://github.com/mattermost/mattermost-server

  8. Clone the Mattermost source code from your fork:

    git clone https://github.com/YOUR_GITHUB_USERNAME/mattermost-server.git
  9. Start the server and test your environment:

    cd mattermost-server
    make run-server
    curl http://localhost:8065/api/v4/system/ping
    make stop-server

    If successful, the curl step will return a JSON object:

    {"AndroidLatestVersion":"","AndroidMinVersion":"","DesktopLatestVersion":"","DesktopMinVersion":"","IosLatestVersion":"","IosMinVersion":"","status":"OK"}

    Note: Browsing directly to http://localhost:8065/ will display a 404 Not Found until the web app is configured. See Web App Developer Setup and Mobile App Developer Setup for additional setup.

    The stop-server make target does not stop all the docker containers started by run-server. To stop the running docker containers:

    make stop-docker
  1. Install and setup Docker.

    Note: MM-9791 introduced using docker-compose to manage containers. To preserve your data on upgrade, execute the following steps.

    First, backup from any existing containers:

    mysqldump -h 127.0.0.1 --column-statistics=0 -u mmuser -p mattermost_test > mm_mysql_backup.sql
    pg_dump -U mmuser -W -d mattermost_test -h 127.0.0.1 > mm_postgres_backup.bak

    Then after upgrading and starting the new docker-compose managed containers, restore the data:

    mysql -u mmuser -p -h 127.0.0.1 mattermost_test < mm_mysql_backup.sql
    psql -U mmuser -W -h 127.0.0.1 -f mm_postgres_backup.bak mattermost_test

    If you don’t migrate your data, the new, docker-compose-managed containers will start out empty. To remove the old containers – destroying any existing data – use make clean-old-docker.

  2. Download and install Go from https://golang.org/dl/

  3. Install and setup babun from http://babun.github.io/

  4. Setup the following environment variables (change the paths accordingly):

    export PATH="/c/Program Files/go/bin":$PATH
    export PATH="/c/Program Files/nodejs":$PATH
    export PATH="/c/Program Files/Git/bin":$PATH
    export GOROOT="c:\\Program Files\\go"
    export GOPATH="c:\\User\\{user-name}\\go"
    export PATH="/c/Program Files/Docker Toolbox":$PATH # change the path accordingly if you are using Docker for Windows
    eval $(docker-machine env default) # skip this line if you are using Docker for Windows
  5. Fork https://github.com/mattermost/mattermost-server

  6. Clone the Mattermost source code from your fork:

    git clone https://github.com/YOUR_GITHUB_USERNAME/mattermost-server.git
  7. Start the server and test your environment:

    cd mattermost-server
    make run-server
    curl http://localhost:8065/api/v4/system/ping
    make stop-server

    If successful, the curl step will return a JSON object containing "status":"OK".

    Note: Browsing directly to http://localhost:8065/ will display a 404 Not Found until the web app is configured. See Web App Developer Setup and Mobile App Developer Setup for additional setup.

    The stop-server make target does not stop all the docker containers started by run-server. To stop the running docker containers:

    make stop-docker

This is an unofficial guide. Community testing, feedback and improvements are welcome and greatly appreciated.

  1. Install the Windows Subsystem for Linux: https://docs.microsoft.com/en-us/windows/wsl/install-win10

  2. Install and setup Docker:

    Note: MM-9791 introduced using docker-compose to manage containers. To preserve your data on upgrade, execute the following steps.

    First, backup from any existing containers:

    mysqldump -h 127.0.0.1 --column-statistics=0 -u mmuser -p mattermost_test > mm_mysql_backup.sql
    pg_dump -U mmuser -W -d mattermost_test -h 127.0.0.1 > mm_postgres_backup.bak

    Then after upgrading and starting the new docker-compose managed containers, restore the data:

    mysql -u mmuser -p -h 127.0.0.1 mattermost_test < mm_mysql_backup.sql
    psql -U mmuser -W -h 127.0.0.1 -f mm_postgres_backup.bak mattermost_test

    If you don’t migrate your data, the new, docker-compose-managed containers will start out empty. To remove the old containers – destroying any existing data – use make clean-old-docker.

  3. Install docker-compose (using bash)

    sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
  4. Install Go using bash (modify installation to latest Go version from https://golang.org/dl/):

    sudo apt-get install -y build-essential
    sudo rm -rf /usr/local/go
    wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz
    sudo tar -C /usr/local -xzf go1.13.3.linux-amd64.tar.gz
  5. Set up your Go workspace:

    1. In PowerShell mkdir d:\Projects\go
    2. In bash ln -s "/mnt/d/Projects/go" /home/<Linux User>/go
  6. Update your shell’s initialization script (e.g. .bashrc or .zshrc) and add the following:

    export GOPATH=$HOME/go
    export PATH=$PATH:$GOPATH/bin
    export PATH=$PATH:/usr/local/go/bin
    ulimit -n 8096
  7. Reload your bash configuration to effect the changes above:

    source ~/.bashrc
  8. Fork Mattermost server on GitHub from https://github.com/mattermost/mattermost-server.

  9. Clone the Mattermost source code from your fork:

    git clone https://github.com/YOUR_GITHUB_USERNAME/mattermost-server.git
  10. Start the server and test your environment:

    cd mattermost-server
    make run-server
    curl http://localhost:8065/api/v4/system/ping
    make stop-server

    If successful, the curl step will return a JSON object containing "status":"OK".

    Note: Browsing directly to http://localhost:8065/ will display a 404 Not Found until the web app is configured. See Web App Developer Setup and Mobile App Developer Setup for additional setup.

    The stop-server make target does not stop all the docker containers started by run-server. To stop the running docker containers:

    make stop-docker

Troubleshooting: 

  1. If you see an error like the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'. Reinstall git for windows and make sure you choose Use Windows' default console window instead of Use MinTTY
  2. The LDAP docker container is sometimes slow to start. If you see the following message, either increase the wait time in the make file or run make run twice in a row.

    Ldap test user test.one
    starting mattermost-openldap
    ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
    ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
    ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
    ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
    ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
    ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
    Makefile:102: recipe for target 'start-docker' failed
    
  1. Install and configure Docker CE:

     sudo pacman -S docker
     sudo gpasswd -a $USER docker
     sudo systemctl enable docker.service
     sudo systemctl start docker.service
     newgrp docker

    Note: MM-9791 introduced using docker-compose to manage containers. To preserve your data on upgrade, execute the following steps.

    First, backup from any existing containers:

    mysqldump -h 127.0.0.1 --column-statistics=0 -u mmuser -p mattermost_test > mm_mysql_backup.sql
    pg_dump -U mmuser -W -d mattermost_test -h 127.0.0.1 > mm_postgres_backup.bak

    Then after upgrading and starting the new docker-compose managed containers, restore the data:

    mysql -u mmuser -p -h 127.0.0.1 mattermost_test < mm_mysql_backup.sql
    psql -U mmuser -W -h 127.0.0.1 -f mm_postgres_backup.bak mattermost_test

    If you don’t migrate your data, the new, docker-compose-managed containers will start out empty. To remove the old containers – destroying any existing data – use make clean-old-docker.

  2. Install docker-compose

    sudo pacman -S docker-compose
  3. Install Go:

    sudo pacman -S base-devel
    sudo pacman -S go
  4. Update your shell’s initialization script (e.g. .bashrc or .zshrc) and add the following:

    export GOPATH=$HOME/go
    export PATH=$PATH:$GOPATH/bin
    export PATH=$PATH:/usr/local/go/bin
  5. Edit /etc/security/limits.conf as an administrator (e.g. sudo) and add the following lines, replacing {username} with your username:

    {username}  soft  nofile  8096
    {username}  hard  nofile  8096
  6. Logout and login to effect the changes above.

  7. Fork https://github.com/mattermost/mattermost-server

  8. Clone the Mattermost source code from your fork:

    git clone https://github.com/YOUR_GITHUB_USERNAME/mattermost-server.git
  9. Start the server and test your environment:

    cd mattermost-server
    make run-server
    curl http://localhost:8065/api/v4/system/ping
    make stop-server

    If successful, the curl step will return a JSON object:

    {"AndroidLatestVersion":"","AndroidMinVersion":"","DesktopLatestVersion":"","DesktopMinVersion":"","IosLatestVersion":"","IosMinVersion":"","status":"OK"}

    Note: Browsing directly to http://localhost:8065/ will display a 404 Not Found until the web app is configured. See Web App Developer Setup and Mobile App Developer Setup for additional setup.

    The stop-server make target does not stop all the docker containers started by run-server. To stop the running docker containers:

    make stop-docker
  1. Install and configure Docker CE:

    curl -fsSL https://get.docker.com -o get-docker.sh
    sudo sh get-docker.sh
    sudo usermod -aG docker $(whoami)
    docker login

    If you prefer to perform these steps manually:

    Note: MM-9791 introduced using docker-compose to manage containers. To preserve your data on upgrade, execute the following steps.

    First, backup from any existing containers:

    mysqldump -h 127.0.0.1 --column-statistics=0 -u mmuser -p mattermost_test > mm_mysql_backup.sql
    pg_dump -U mmuser -W -d mattermost_test -h 127.0.0.1 > mm_postgres_backup.bak

    Then after upgrading and starting the new docker-compose managed containers, restore the data:

    mysql -u mmuser -p -h 127.0.0.1 mattermost_test < mm_mysql_backup.sql
    psql -U mmuser -W -h 127.0.0.1 -f mm_postgres_backup.bak mattermost_test

    If you don’t migrate your data, the new, docker-compose-managed containers will start out empty. To remove the old containers – destroying any existing data – use make clean-old-docker.

  2. Install docker-compose

    sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
  3. Install Go (modify installation to latest Go version from https://golang.org/dl/):

    sudo yum group install "Development Tools"
    sudo yum install -y wget libpng12
    sudo rm -rf /usr/local/go
    wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz
    sudo tar -C /usr/local -xzf go1.13.3.linux-amd64.tar.gz
  4. Update your shell’s initialization script (e.g. .bashrc or .zshrc) and add the following:

    export GOPATH=$HOME/go
    export PATH=$PATH:$GOPATH/bin
    export PATH=$PATH:/usr/local/go/bin
  5. Edit /etc/security/limits.conf as an administrator (e.g. sudo) and add the following lines, replacing {username} with your username:

    {username}  soft  nofile  8096
    {username}  hard  nofile  8096
  6. Logout and login to effect the changes above.

  7. Fork https://github.com/mattermost/mattermost-server

  8. Clone the Mattermost source code from your fork:

    git clone https://github.com/YOUR_GITHUB_USERNAME/mattermost-server.git
  9. Start the server and test your environment:

    cd mattermost-server
    make run-server
    curl http://localhost:8065/api/v4/system/ping
    make stop-server

    If successful, the curl step will return a JSON object:

    {"AndroidLatestVersion":"","AndroidMinVersion":"","DesktopLatestVersion":"","DesktopMinVersion":"","IosLatestVersion":"","IosMinVersion":"","status":"OK"}

    Note: Browsing directly to http://localhost:8065/ will display a 404 Not Found until the web app is configured. See Web App Developer Setup and Mobile App Developer Setup for additional setup.

    The stop-server make target does not stop all the docker containers started by run-server. To stop the running docker containers:

    make stop-docker