Writing Mattermost plugins with VSCode and Docker

Mattermost Plugins

Mattermost is a great communication platform and in most areas can compete with its commercial alternatives Slack and Microsoft Teams. The one thing where Mattermost is lacking though is the availabitlity of extensions via plugins. The infrastructure is ready, there’s even a marketplace available. There just aren’t many plugins in there.

Recently I thought about a few cool ideas that could be done with plugins and decided to give it a try. Mainly those plugins are written in Go, a language I have no experience with. What a great excuse to try out a few new things 🙂

Instead of setting up my system with Go I decided to try out the Remote Development extension of VSCode. This approach connects the local VSCode-client with a VSCode-server running in a Docker container. It’s possible to develop in a native Linux environment that way, while still being on a Windows computer. It’s also possible to create reproducible dev environments with all the necessary tools – without cluttering the whole system. Everything is nice and isolated.

Setting up the dev environment

  • Clone the mattermost-plugin-starter-template
  • Make sure your Docker configuration allows containers to use 8GB of RAM, else NPM will get stuck later on
  • Start VSCode and install the Remote Development environment
  • Click bottom left: “Remote-containers: Open folder in container”
  • Select your cloned plugin-repo
  • Select the Go dev image. This takes a while to get built.
  • When running you need to install npm in order for the Mattermost-plugin to get built:

Setting up the test environment

  • Clone the mattermost-docker repo
  • Change the docker-compose.yml
    • You do not need to map any volumes for testing
    • Use the Team version of Mattermost. This is enough for testing
  • Run everything with docker-compose up
  • Once running connect to the app-container: docker exec -it XXXX /bin/sh
  • Enable manual uploading of plugins within the config.json: sed -i 's/"EnableUploads": false/"EnableUploads": true/' config/config.json
  • Restart the test environment

Upload a plugin

  • Go to the Mattermost System Console
  • Upload the generated plugin and enable it

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s