Deploying a Mattermost App
Introduction
Mattermost is an open-source, self-hosted collaboration platform built on Go and React. Deploying Mattermost with a Dockerfile on Klutch.sh provides reproducible builds, managed secrets, and persistent storage for configuration, plugins, and files—all from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, and sample API usage.
Prerequisites
- A Klutch.sh account (sign up)
- A GitHub repository containing your Mattermost configuration and Dockerfile (GitHub is the only supported git source)
- A PostgreSQL database (deploy as a Klutch.sh TCP app on port
8000and connect on5432) - Optional object storage (S3-compatible) for file uploads
- Domain ready for your Mattermost workspace
For onboarding, see the Quick Start.
Architecture and ports
- Mattermost web/API listens on internal port
8065; choose HTTP traffic. - PostgreSQL runs separately as a TCP app; connect on
5432. - Persistent storage is required for config, data, logs, and plugins.
Repository layout
mattermost/├── Dockerfile # Must be at repo root for auto-detection├── config/ # config.json and settings (persist)├── data/ # file uploads (persist) if not using S3├── logs/ # application logs (persist)├── plugins/ # server plugins (persist)├── client/plugins/ # web app plugins (persist)└── README.mdKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Validate locally before pushing to GitHub:
docker build -t mattermost-local .docker run -p 8065:8065 --env-file .env mattermost-localDockerfile for Mattermost (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM mattermost/mattermost-team-edition:latest
WORKDIR /mattermost
# Copy custom plugins/themes if you keep them in-repoCOPY plugins ./pluginsCOPY client/plugins ./client/plugins
# Ensure writable directories existRUN mkdir -p ./config ./data ./logs && \ chown -R mattermost:mattermost ./config ./data ./logs ./plugins ./client/plugins
EXPOSE 8065CMD ["mattermost"]Notes:
- The image bundles the Mattermost server and web app. If you rely on S3 for file storage, you can keep
data/minimal but still persist logs and plugins. - Add health checks or reverse proxy headers in your upstream if needed.
Environment variables (Klutch.sh)
Set these in Klutch.sh before deploying:
MM_SERVICESETTINGS_SITEURL=https://example-app.klutch.shMM_SERVICESETTINGS_LISTENADDRESS=:8065MM_SQLSETTINGS_DRIVERNAME=postgresMM_SQLSETTINGS_DATASOURCE=postgres://<user>:<password>@<db-host>:5432/<db-name>?sslmode=disableMM_FILESETTINGS_MAXFILESIZE=52428800(example: 50MB)MM_LOGSETTINGS_ENABLECONSOLE=true- Optional SMTP:
MM_EMAILSETTINGS_SMTPSERVER,MM_EMAILSETTINGS_SMTPPORT,MM_EMAILSETTINGS_SMTPUSERNAME,MM_EMAILSETTINGS_SMTPPASSWORD,MM_EMAILSETTINGS_FEEDBACKEMAIL - Optional S3:
MM_FILESETTINGS_DRIVERNAME=amazons3,MM_FILESETTINGS_AMAZONS3ACCESSKEYID,MM_FILESETTINGS_AMAZONS3SECRETACCESSKEY,MM_FILESETTINGS_AMAZONS3BUCKET,MM_FILESETTINGS_AMAZONS3ENDPOINT,MM_FILESETTINGS_AMAZONS3REGION,MM_FILESETTINGS_AMAZONS3SSL=true - Any additional plugin-specific keys your deployment requires
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_START_CMD=mattermostNIXPACKS_GO_VERSION=1.20
Attach persistent volumes
In Klutch.sh storage settings, add mount paths and sizes (no names required):
/mattermost/config— configuration and licensing data./mattermost/data— file uploads if not offloaded to S3./mattermost/logs— application logs./mattermost/plugins— server plugins./mattermost/client/plugins— web app plugins.
Ensure these directories are writable.
Deploy Mattermost on Klutch.sh (Dockerfile workflow)
- Push your repository—with the Dockerfile at the root—to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Select HTTP traffic and set the internal port to
8065. - Add the environment variables above, including Postgres, SMTP, and optional S3 settings.
- Attach persistent volumes for
/mattermost/config,/mattermost/data,/mattermost/logs,/mattermost/plugins, and/mattermost/client/pluginswith sizes that match your retention needs. - Deploy. Your Mattermost instance will be reachable at
https://example-app.klutch.sh; connect a custom domain if desired.
Sample API usage
Health check:
curl -X GET "https://example-app.klutch.sh/api/v4/system/ping"Create a user (requires admin token):
curl -X POST "https://example-app.klutch.sh/api/v4/users" \ -H "Authorization: Bearer <admin_token>" \ -H "Content-Type: application/json" \ -d '{"email":"newuser@example.com","username":"newuser","password":"P@ssw0rd123"}'Health checks and production tips
- Add an HTTP probe to
/api/v4/system/pingfor readiness. - Enforce HTTPS at the edge; route internally to port
8065. - Keep lockfiles and plugin versions pinned; test upgrades in staging.
- Monitor database connections and file storage; resize volumes before they fill.
- Store secrets only in Klutch.sh and rotate them regularly.
- Offload file storage to S3 for large teams; keep logs and plugins persisted locally.
Mattermost on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root, port 8065 configured, and Postgres connected, you can deliver a reliable collaboration platform without extra YAML or workflow overhead.