Skip to main content
Mattermost Team Edition is the open-source, self-hosted version of Mattermost’s team messaging platform. If you want full control over your team’s communication data without relying on a third-party SaaS service, it’s a solid choice. On Upsun, the infrastructure is defined entirely in a single YAML file, and the deployment lifecycle is automated through build, deploy, and post-deploy hooks. This article walks through the template that deploys Mattermost Team Edition 11.4.0 on Upsun, backed by PostgreSQL 16 for storage and OpenSearch 2 for full-text message search.
The template used in this article is a community-maintained deployment template, not an official Upsun-supported project.

What you’ll deploy

The template sets up the following stack:

Prerequisites

Clone the template

The repository already contains all the configuration you need. No application code is written by you — the build hook downloads the Mattermost binary directly.

How the configuration works

The infrastructure file

Everything Upsun needs to provision your environment lives in .upsun/config.yaml:
A few things worth noting:
  • Seven persistent mounts keep Mattermost’s config, logs, data, and plugin directories intact across deployments. These use instance storage, so they’re local to each container rather than shared.
  • Routes send all traffic to www.{default} and redirect the bare domain to it. Caching is disabled because Mattermost serves dynamic content.
  • The start command runs the Mattermost binary directly — there’s no additional web server in front of it.

The build hook

The build.sh script runs during the build phase, before the container is deployed:
The version is read from the mattermost_version file (currently 11.4.0). The tarball is cached in PLATFORM_CACHE_DIR so subsequent builds skip the download if the version hasn’t changed. After extraction, a copy of the default config.json is saved as config.default for the deploy hook to restore if needed.

The deploy hook

deploy.sh runs after each build before the app starts:
It restores config.json from the backup if the file is missing or empty, and ensures the local socket directory exists. Any stale non-socket file at the socket path is removed to prevent Mattermost from failing to bind on startup.

The post-deploy hook

postdeploy.sh runs once after the app has started, but only on the first deployment:
The script uses mmctl (the Mattermost CLI bundled with the binary) in local socket mode to:
  1. Wait up to 30 seconds for the Unix socket to be ready
  2. Generate a cryptographically random admin password (20 alphanumeric characters plus !9Aa to satisfy complexity rules)
  3. Create the admin user (admin / admin@example.com) and save the password to .config/admin_credentials
  4. Create a private team (team-admin) and a channel (setup)
  5. Post welcome and warning messages into the channel
  6. Write a .config/upsun.installed marker so this block never runs again

Environment variables

The .environment file is sourced on every container start and runtime event. It translates Upsun’s platform variables into Mattermost’s MM_* configuration format:
PLATFORM_RELATIONSHIPS and PLATFORM_ROUTES are base64-encoded JSON blobs that Upsun injects at runtime. The .environment file decodes them with jq to extract service hostnames, ports, and credentials without you needing to manage secrets manually. The PSH_* variables at the bottom define the default admin account, first team, first channel, and the welcome messages posted on first deploy.

Deploy to Upsun

Create a new Upsun project from the repository root:
Follow the CLI prompts to name your project and select a region. Then push to deploy:
The first deployment takes a few minutes. The build hook downloads the Mattermost binary (~200 MB), and the post-deploy hook initializes the admin account after the app starts.

Retrieve your admin credentials

After the first deployment completes, SSH into the app container and read the credentials file:
This prints the randomly generated password for the admin account. Open your site URL to log in:
Change your admin password immediately after first login. Go to Account Settings in the top-right toolbar and update your credentials.

Updating Mattermost Team Edition

To upgrade to a newer version, update the version number in mattermost_version, commit the change, and push:
The build hook will download the new tarball (or use a cached copy if it already downloaded it), and Upsun’s zero-downtime deployment will replace the running instance.

Plugins

The plugins and client/plugins mounts persist across deployments, so any plugins you install through the Mattermost marketplace or by uploading a plugin bundle survive redeployments. Plugin uploads are enabled by default via MM_PLUGINSETTINGS_ENABLEUPLOADS=true in .environment.

Conclusion

This template gives you a fully functional Mattermost Team Edition instance on Upsun with no manual infrastructure setup. PostgreSQL and OpenSearch are provisioned automatically, the admin account is created on first deploy, and all configuration is driven by environment variables — so there are no secrets in your repository. Get started with a free Upsun account at upsun.com.
Last modified on April 27, 2026