Set up your development environment for building, running, and testing Mattermost.
Prerequisites for Windows
If you're using Windows, we recommend using the Windows Subsystem for Linux (WSL) for Mattermost development. Go and Node must be run from within WSL, so you'll need to install them in WSL even if you already have the Windows versions of them installed.
- Install WSL by running the following command as an administrator in PowerShell:
wsl --install - Install Docker Desktop for Windows on your Windows machine. Alternatively, you can also install docker engine directly on your linux distribution.
- Perform the rest of the operations (except Docker installation) within the WSL environment and not in Windows.
Setup the Mattermost Server
-
Install
make.-
On Ubuntu, you can install
build essentialtools which will also take care of installing themake:sudo apt install build-essential
-
-
Install and run Docker. If you don't want to use Docker, you can follow this guide.
- When running
dockercommands under WSL2, if you receive the errorThe command 'docker' could not be found in this WSL 2 distro.you may need to toggle theUse the WSL 2 based engineoff and on within Docker Settings after installation. - Make sure that Docker has virtual file share access to the directory that you will clone the repository in
- When running
-
Install Go.
- Version 1.21 or higher is required.
-
Increase the number of available file descriptors. Update your shell's initialization script (e.g.
.bashrcor.zshrc), and add the following:ulimit -n 8096 -
If you don't have it already, install libpng with your preferred package manager.
-
If you are on ARM based Mac, you'll need to install Rosetta to make
libpngwork. Rosetta can be installed by the following command-softwareupdate --install-rosetta
-
-
Clone the Mattermost source code from your fork:
git clone https://github.com/YOUR_GITHUB_USERNAME/mattermost.git -
Install NVM and use it to install the required version of Node.js:
-
Install NVM by following these instructions.
-
Then, use NVM to install the correct version of Node.js for the Mattermost web app (this should be run within the
webappdirectory):nvm install
-
-
Start the server:
cd servermake run-server -
Test your environment to ensure that the server is running:
curl http://localhost:8065/api/v4/system/pingIf successful, the
curlstep will return a JSON object:{"AndroidLatestVersion":"","AndroidMinVersion":"","DesktopLatestVersion":"","DesktopMinVersion":"","IosLatestVersion":"","IosMinVersion":"","status":"OK"} -
Set up up your admin user using mmctl:
bin/mmctl user create --local --email ADMIN_EMAIL --username ADMIN_USERNAME --password ADMIN_PASSWORD --system-admin-
Optionally, you can also populate the database with random sample data as well:
bin/mmctl sampledata
-
-
Start the web app:
cd webappmake run -
Open the web app by going to http://localhost:8065 in your browser or by adding it to the Mattermost desktop app.
-
Stop the server:
make stop-serverThe
stop-servermake target does not stop all the docker containers started byrun-server. To stop the running docker containers:make stop-docker -
Set your options:
Some behaviors can be customized such as running the server in the foreground as described in the
config.mkfile in the server directory. See that file for details.
Build the Mattermost Server
The make package command will package the application and place it under the ./dist directory. You can distribute the .tar.gz file if you wish the run the application elsewhere. Note that you would need to run make build before this to build the binaries.
Develop Mattermost without Docker
-
Install
make.- On Ubuntu, you can install
build essentialtools which will also take care of installing themake:sudo apt install build-essential
- On Ubuntu, you can install
-
Copy the file
server/config.mkasserver/config.override.mkand setMM_NO_DOCKERtotruein the copy. -
Install PostgreSQL
-
Run
psql postgres. Then createmmuserby runningCREATE ROLE mmuser WITH LOGIN PASSWORD 'mostest_password'; -
Modify the role to give rights to create a database by running
ALTER ROLE mmuser CREATEDB; -
Confirm the role rights by running
\du -
Before creating the database, exit by running
\q -
Login again via
mmuserby runningpsql postgres -U mmuser -
Create the database by running
CREATE DATABASE mattermost_test;and exit again with\q -
Login again with
psql postgresand runGRANT ALL PRIVILEGES ON DATABASE mattermost_test TO mmuser;to give all rights tommuser -
Install Go.
-
Increase the number of available file descriptors. Update your shell's initialization script (e.g.
.bashrcor.zshrc), and add the following:ulimit -n 8096 -
If you don't have it already, install libpng with your preferred package manager.
- If you are on ARM based Mac, you'll need to install Rosetta to make
libpngwork. Rosetta can be installed by the following command-softwareupdate --install-rosetta
- If you are on ARM based Mac, you'll need to install Rosetta to make
-
Clone the Mattermost source code from your fork:
git clone https://github.com/YOUR_GITHUB_USERNAME/mattermost.gitcd mattermost -
Install NVM and use it to install the required version of Node.js:
- First, install NVM by following these instructions.
- Then, use NVM to install the correct version of Node.js for the Mattermost web app (this should be run within the
webappdirectory):cd webappnvm installcd .. - NOTE: If you get
zsh: command not found: nvmwhen runningnvm install, you will need to add the following to your ~/.zshrc file:export NVM_DIR="$HOME/.nvm"[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
-
Start the server:
cd servermake run-server -
Test your environment to ensure that the server is running by running the following in a different terminal session:
curl -s http://localhost:8065/api/v4/system/ping | jq .If successful, the
curlstep will return a JSON object:{"AndroidLatestVersion":"","AndroidMinVersion":"","DesktopLatestVersion":"","DesktopMinVersion":"","IosLatestVersion":"","IosMinVersion":"","status":"OK"}Alternately, you can enter
http://localhost:8065/api/v4/system/pingin a web browser. -
Set up up your admin user using mmctl:
bin/mmctl user create --local --email ADMIN_EMAIL --username ADMIN_USERNAME --password ADMIN_PASSWORD --system-admin-
Note:
ADMIN_PASSWORDmust be 8 characters or more. -
Optionally, you can also populate the database with random sample data as well:
bin/mmctl --local sampledata
-
-
Start the web app (in another terminal window):
cd PATH_TO_MATTERMOST_REPO/webappmake run -
Open the web app by going to http://localhost:8065 in your browser or by adding it to the Mattermost desktop app.
-
Stop the server:
cd PATH_TO_MATTERMOST_REPO/servermake stop-server -
Set your options: Some behaviors can be customized such as running the server in the foreground as described in the
config.mkfile in the server directory. See that file for details.