Installing Mattermost for the Fun of it

Mattermost - Collaborate securely and privately

Sounds good to you? Like it? So do I. Let’s give it a try…

Since we have a lot of Docker know-how I looked for a Docker-based installation and found Production Docker deployment for Mattermost.

We already have a reverse proxy in place and are Using a PostgreSQL with Docker like a Pro, thus I went down the path of creating a basic docker-compose.yaml based on the one found in the repo mentioned above.

Take it step-by-step…

The PostgreSQL

This post is more about Mattermost, so we only cover the surface of this part of the setup:

Within docker-compose.yaml we declare a service postgres that uses the script mattermost-setup.sh to create a database user psql_admin as well as a database mattermost.

Fire up the service with:

$ docker-compose up -d postgres

then verify the result using psql:

$ docker exec -it mattermost_postgres_1 psql -U psql_admin -d mattermost

For more in-depth details please visit our post Using a PostgreSQL with Docker like a Pro.

Mattermost itself

Our first try with a dedicated Mattermost team image mattermost/mattermost-team-edition failed (Always complained about missing licenses - didn’t investigate this any further). So we stripped all sophisticated stuff from this Dockerfile and came up with our own version of a Mattermost team flavor:

FROM alpine:3.7

# Some ENV variables
ENV MM_VERSION=5.6.2

# Install some needed packages
RUN apk add --no-cache \
    ca-certificates \
    curl \
    jq \
    libc6-compat \
    libffi-dev \
    linux-headers \
    mailcap \
    netcat-openbsd \
    xmlsec-dev \
    && rm -rf /tmp/*

# Get Mattermost
RUN mkdir -p /mattermost/data /mattermost/plugins /mattermost/client/plugins \
    && curl https://releases.mattermost.com/$MM_VERSION/mattermost-team-$MM_VERSION-linux-amd64.tar.gz | tar -xvz \
    && cp /mattermost/config/config.json /config.json.save \
    && rm -rf /mattermost/config/config.json

# Configure entrypoint
ENTRYPOINT ["mattermost"]
WORKDIR /mattermost

# Expose port 8065 of the container
EXPOSE 8065

Within the following docker-compose.yaml we reference our Mattermost Dockerfile to complete the setup:

  mattermost:
    build: mattermost
    ports:
      - 127.0.0.1:8065:8065
    volumes:
      - ./mattermost/config/config.json:/config/config.json
      - mattermost-data:/mattermost/data
      - mattermost-logs:/mattermost/logs
      - mattermost-plugins:/mattermost/plugins
      - mattermost-client-plugins:/mattermost/client/plugins

Get it up and running alongside the service postgres with:

$ docker-compose up -d mattermost

You should be able to access your local installation via http://localhost:8065

Create the first admin user and team

To set up our installation we used the Command Line Tools from Mattermost.

Create an interactive session with the mattermost container:

$ docker-compose exec mattermost /bin/sh

Inside the container - fire the commands to create your admin + team:

/mattermost # mattermost user create --firstname Joe --system_admin --email joe@example.com --username joe --password Password1
/mattermost # mattermost team create --name mynewteam --display_name "My New Team"
/mattermost # mattermost team add mynewteam joe@example.com joe

Enjoy your project with your freshly created team chat!

Cleanup

If your project is finished or you want to get rid of the Mattermost installation due to other reasons bring down your setup with:

$ docker-compose down --volumes

Bonus: Dry-run on a Mac

Things I learned during this unsuccessful dry-run:

  • How to prepare a group mattermost with GID 2000 via “Users & Groups” in the system preferences dialog (@see answer on StackExchange).
  • How to get the UID with id -u and the GID with id -g of your current user.