Skip to content

Instantly share code, notes, and snippets.

@vukhanhtruong
Last active September 19, 2020 02:27
Show Gist options
  • Save vukhanhtruong/d97ba31cd8e67633721c75f2139704b4 to your computer and use it in GitHub Desktop.
Save vukhanhtruong/d97ba31cd8e67633721c75f2139704b4 to your computer and use it in GitHub Desktop.
Mattermost using the Docker setup together with nginx-proxy, using the LetsEncrypt companion container for nginx-proxy for automatic renew ssl.

Getting Started

First, create a Docker network. This enables container DNS, which allows containers to communicate with one another by name.

docker network create mattermostnw

Customize the nginx-proxy settings

  • Read the official Mattermost docker here
  • Read the Nginx-proxy documentation here

Start the Nginx proxy

docker run --name nginx-proxy --net mattermostnw -p 80:80 -p 443:443 -v /path/to/nginx-custom.conf:/etc/nginx/conf.d/my_proxy.conf:ro -v ~/certs:/etc/nginx/certs -v /etc/nginx/vhost.d -v /usr/share/nginx/html -v /var/run/docker.sock:/tmp/docker.sock:ro --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy -d --restart always jwilder/nginx-proxy

Note: Remember change the mounted paths to your own

Start the Let’s Encrypt Nginx Proxy Companion.

docker run --name letsencrypt-nginx-proxy-companion --net mattermostnw -v ~/certs:/etc/nginx/certs:rw -v /var/run/docker.sock:/var/run/docker.sock:ro --volumes-from nginx-proxy -d --restart always jrcs/letsencrypt-nginx-proxy-companion

Start Mattermost

  • Pulling the latest Mattermost docker
  • Copy override docker-compose.yml to mattermost-docker folder
  • Run docker-compose build && docker-compose up -d

Credits

version: "2"
services:
db:
build: db
read_only: true
restart: unless-stopped
volumes:
- ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data
- /etc/localtime:/etc/localtime:ro
environment:
- POSTGRES_USER=mmuser
- POSTGRES_PASSWORD=mmuser_password
- POSTGRES_DB=mattermost
networks:
- mattermostnw
app:
build:
context: app
restart: unless-stopped
volumes:
- ./volumes/app/mattermost/config:/mattermost/config:rw
- ./volumes/app/mattermost/data:/mattermost/data:rw
- ./volumes/app/mattermost/logs:/mattermost/logs:rw
- ./volumes/app/mattermost/plugins:/mattermost/plugins:rw
- /etc/localtime:/etc/localtime:ro
environment:
# set same as db credentials and dbname
- MM_USERNAME=mmuser
- MM_PASSWORD=mmuser_password
- MM_DBNAME=mattermost
- VIRTUAL_HOST=chat.yourdomain.com
- VIRTUAL_PORT=8000
- LETSENCRYPT_HOST=chat.yourdomain.com
- LETSENCRYPT_EMAIL=admin@chat.yourdomain.com
ports:
- "8000:8000"
expose:
- "8000"
networks:
- mattermostnw
networks:
mattermostnw:
external: true
client_max_body_size 50M;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
proxy_read_timeout 600s;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment