Month: May 2019

Mattermost Server Docker Installation Tutorial

Introduction

This tutorial covers how to setup mattermost, an open-source and free slack alternative with docker on a domain or subdomain with SSL. The deployment, which results from this tutorial is production ready.

Background: Why Mattermost?

DriveTrust started as a small team, back then slack has been a good solution. However, we grew and with 10 people we have reached our 10K message limit for slack quiet quick. Now paying 7,50€ / user / month seemed to expensive for a comparably simple chat application, so we started looking for better alternatives.

Mattermost Pros & Cons

Pros:

1. free & self hosted.

2. A close to 1:1 clone of Slack, it has its own Android & iOS application

3. Has an export feauture from Slack, so the migration is quiet simple

Cons:

1. Currently no guest user feature support

2. During migration private messages are not exported, as well we have not managed to export all the files

Requirements

From DriveTrust’s side there have been a few requirements:

1. Integration with our existing applications on the server

2. Running on the subdomain chat.drivetrust.eu

3. SSL

4. Running within docker

5. Being a capable production deployment

Implementation

Prerequisites

1. Docker & Docker Compose

2. DNS A record pointing to domain/subdomain. (In our case chat.drivetrust.eu ) and server with a dedicated IP

3. jwilder nginx proxy and jwilder letsencrypt nginx proxy companion
Both are needed to reverse proxy the domain https://chat.drivetrust.eu to a docker container which is located on a different port. Because we don’t want to have some URL like chat.drivetrust.eu:9097 for production.
The second container automatically generates free SSL certificates for each subdomain you run with the nginx proxy.

0. Setup reverse proxy and SSL

This part refers to the above-mentioned containers. Once docker has installed the running of the containers is straight forward. This is straight from the official tutorial from Github
with one minor modification.

docker network create nginx-net

Before getting started with the servers and the reverse proxy we need to create a docker network to which will attach the nginx-proxy, the letsencrypt proxy ssl and the mattermost containers. Once the network is created we run the following two commands:

 docker run --detach \
    --name nginx-proxy \
    --publish 80:80 \
    --publish 443:443 \
    --net nginx-net \
    --volume /etc/nginx/certs \
    --volume /etc/nginx/vhost.d \
    --volume /usr/share/nginx/html \
    --volume /var/run/docker.sock:/tmp/docker.sock:ro \
    jwilder/nginx-proxy

 docker run --detach \
    --name nginx-proxy-letsencrypt \
    --volumes-from nginx-proxy \
    --net nginx-net \
    --volume /var/run/docker.sock:/var/run/docker.sock:ro \
    --env "DEFAULT_EMAIL=YOUR_EMAIL_ADDRESS" \
    jrcs/letsencrypt-nginx-proxy-companion

Now you should have the reverse proxy setup!

Mattermost installation

The official mattermost tutorial deploys mattermost as a docker service. This has not been suitable for us since we were looking to integrate with our existing Nginx Proxy Server. That’s why took apart the docker-compose.yml and rebuild everything from scratch. In total we will have three different docker containers, one for database, one for the app and one for the web application.

Step 1: create the local volume directories where the data will be stored:

mkdir -pv /srv/mattermost/volumes/app/mattermost/{data,logs,config,plugins,client-plugins} <br>
chown -R 2000:2000 /srv/mattermost/

Step 2: get the official mattermost git repo:

git clone https://github.com/mattermost/mattermost-docker.git 
cd mattermost

Step 3: a )Build the database container.

cd db 
docker build -t mattermost_db 

That should build the database container.

b) Run the container

docker run --detach
 --name mattermost-docker_db_1 
 --restart unless-stopped
 --env POSTGRES_USER=mmuser
 --env POSTGRES_PASSWORD=YOUR_DATABASE_PASSWORD
 --env POSTGRES_DB=mattermost
 --net nginx-net
 --volume /srv/mattermost/var/lib/postgresql/data:/var/lib/postgresql/data

Replace YOUR_DATABASE_PASSWORD with a proper database password. Please note that we add the container to nginx-net network to integrate with the reverse proxy.

Step 4: a) Build the mattermost app container

Here we need to add –build-arg edition=team to build the team edition of mattermost.

b) Run the container

docker run --detach
 --name mattermost-docker_app_1 
 --restart unless-stopped
 --env MM_USERNAME=mmuser
 --env MM_PASSWORD=YOUR_DATABASE_PASSWORD
 --env MM_DBNAME=mattermost
 --env MM_SERVICESETTINGS_SITEURL="https://chat.drivetrust.eu"
 --net nginx-net
 --env DB_HOST=mattermost-docker_db_1
 --volume /srv/mattermost/app/config:/mattermost/config:rw
 --volume /srv/mattermost/app/data:/mattermost/data:rw
 --volume /srv/mattermost/app/logs:/mattermost/logs:rw 
 --volume /srv/mattermost/app/plugins:/mattermost/plugins:rw
 --volume /srv/mattermost/app/client-plugins:/mattermost/client/plugins:rw
 --volume /etc/localtime:/etc/localtime:ro
mattermost_app:latest

Replace YOUR_DATABASE_PASSWORD with the database password.
Replace MM_SERVICESETTINGS_SITEURL with your URL
Note that the container has as well been added to the nginx-net network
Note that –-env DB_HOST actually requires an IP address of the database. However, since our database is as the app on the nginx-net network we can just pass the database container name (mattermost-docker_db_1) as host and docker does the domain name resolution automatically

Step 5: a) Build the web container

cd web 
 
docker build -t mattermost_web 

b) Run the container:

docker run --detach
 --name mattermost_web
 --restart always
 --env "VIRTUAL_HOST=chat.drivetrust.eu" 
 --env "LETSENCRYPT_HOST=chat.drivetrust.eu" 
 --env "LETSENCRYPT_EMAIL=roman.prytkov@drivetrust.eu"
 --env APP_HOST=mattermost-docker_app_1 
 --env MATTERMOST_ENABLE_SSL=true 
 --net nginx-net
 --expose 9097
 --volume /etc/nginx/certs/chat.drivetrust.eu:/cert:ro 
 --volume /etc/localtime:/etc/localtime:ro 
mattermost_web:latest

Replace VIRTUAL_HOST, LETSENCRYPT_EMAIL, LETSENCRYPT_HOST with your domain. The APP_HOST is the containername of the mattermost app build in 4. It’s the same principle of DNS as with the mattermost database and mattermost app.

That’s it. Now you should be able to see the login screen on the domain of your choice!

How to deal with aggressive drivers on the road ?

Aggressive driving is a serious concern and a real threat to the safety of all road users. In some extreme cases, this can lead to road rage, which is a violent criminal act involving the intent to cause physical harm. Any dangerous, intentional and malicious driving, or driving without consideration for safety, can be considered as aggressive driving.

Aggressiveness occurs when drivers put pressure on themselves because they want to reach their destination as quickly as possible or because they feel provoked by other road users. Frustrations at work or in everyday life can also lead to aggressive behaviour on the road.

What are the types of aggressive behaviors?

  • Headlight calls/blinkers/horns
  • Tighten the vehicle in front, follow it far too closely
  • Deliberately refusing priority to cyclists or pedestrians
  • Brake unnecessarily or block the passing lane
  • Making obscene gestures, insulting

How to avoid aggressiveness?

  • Be aware that by driving aggressively, you will not reach your destination faster, but will become a danger to yourself and others.
  • Don’t put yourself under pressure
  • Only drive if you are in good physical condition (tiredness, thirst, hunger or stress are also factors that can lead to aggressive behaviour.)
  • Be tolerant of yourself and others: we all make mistakes, including you.

By your tolerance, you improve the atmosphere on the roads and contribute to reducing the number of accidents.

How to deal with the aggressive drivers?

  • Stay calm. Put yourself in the position of the “aggressive” driver, there may just be a misunderstanding.
  • Make way and let the other aggressive driver pass
  • Do not tailgate.
  • Always be polite, even if the other person is not.

Preventing distractions while driving

Driving is a serious responsibility that requires skills of perception, analysis, movement, reaction as well as your full attention. Distractions can occur at anytime, anywhere and everywhere.

A distraction is something that takes your mind away from driving. There are four sources of distraction that are potentially disturbing to the driver:

auditive distraction: attention is turned away by what you hear

visual distraction: attention is drawn away by what you see



physical distraction: attention is focused on what you do


Source : Giphy)

cognitive distraction: attention is distracted by thoughts

How to avoid distractions while driving?

  • Place your GPS as close as possible to your field of vision (without obstructing your visibility on the road). Enter your itinerary information before you leave. Learning on how to just use the navigate by listening to the voice of the navigation rather than looking may as well help you to not get distracted
  • Avoid talking or sending text messages on your mobile phone while driving. If you really have a need for sending texts or talking on the phone while driving, there are quite a few ways how you can integrate speech recognition/voice control into your existing car.
  • Do not read while driving. When you need to read or use a map, leave the road.
  • Avoid taking your coat or changing clothes while driving.
  • Make-up, comb hair and/or beard before leaving home or at the office. These things should never be done while driving.
  • Avoid eating or drinking while driving.
  • Listen to music at a reasonable volume. And to reasonable music. Listening to Rammstein’s “Feuer Frei” will more likely make you speed rather than Bob Marley’s “Could you be loved” Listening to music too loud or using headphones or earplugs while driving can be disruptive and can affect your ability to hear emergency vehicles sharing the road with you.
  • Do not light or extinguish cigarettes or deal with ashes that fall while you are driving.

The most important to remember is never multi-tasking while driving!

How Do You Prepare Your Car for A Long Trip?

In Summer and Spring, especially Easter holidays are often a time for family holidays, trips of all kinds. While some people choose to travel by plane or train, most people prefer to travel by car. Before a car trip, it is essential to check 3 major details: the car, the route and the load.

Vehicle check-up before a long trip

Tire Pressure

Check the air pressure of the tires, including the spare tire.

  • If you go for a long trip with a heavy load it’s better to refill more air into the tires, especially it makes sense to put more air into the rear tires because they will have a higher load.
  • Usually, you can refill the air pressure at every petrol station for free, so it’s definitely worth doing
  • However, you should drive maximum 10km before refilling the air pressure, since the tire might get warm which will change the reading

Oil, brake, coolant and windshield washer levels

  • Check the brakes, steering, headlights and lights, battery and wiper blades.
  • Check the levels of oil, brake and coolant fluids, windshield washer…

Essentials to take with you

  • Make sure you have the following items on board: a warning triangle, a safety vest, a medicine kit, wheel change equipment and a flashlight.
  • In summer, think of sunshades and sunglasses. Take enough water and drinks with you.
  • In winter. Don’t forget the antifreeze liquid, a squeegee, gloves and special equipment (chains, snow tires, etc.) in case it is required.

How to properly load a car?

  • Distribute the weights over the entire vehicle. Place the heaviest luggage as low as possible.
  • Do not have any objects before the rear window, so you can see clearly through the rear mirror
  • If you use roof bars, roof box, a bicycle carrier or a trailer, comply with the legal loading rules (exceeding the length of the vehicle, signage, etc.)
    It’s very important to properly tighten and load the goods since those might become a danger to other people in case they fall from the car
  • Load your vehicle the day before departure, if possible.

Road Planning

  • Prepare your route by favouring highways or bigger roads.
  • Find out about traffic conditions and weather forecasts for the entire route. Use apps such as Waze.
  • It’s the holidays, no stress! So, take some time to rest. On the way, take a break as soon as the need is felt, don’t fight against sleep. As a rule of thumb a 30-minute break every two hours of driving
    Avoid leaving after a day’s work, opt instead for an early departure.
    Be aware that you are going away for long hours, remember to put on an outfit in which you feel comfortable to drive. Navigation Systems and Apps

If you don’t want to buy a navigation system, there is no need. If you have a smartphone, you don’t even need a mobile Internet or mobile network connection, GPS works for free without connectivity.
However, you would need to download the maps beforehand, so GoogleMaps is not always the best solution…

Our favourite navigation apps are:

  • Co-Pilot. Download of one map for one country for free
  • Offline Maps & Navigation on Google Play Store. Less quality then Co-Pilot, but completely for free

Pro Tip For Navigation

Learn how to navigate by just listening to the voice of the navigation system. Watching the map while driving is distracting and a potential cause for accidents. So try to just put the navigation system on the speaker and turn off the display.

Dont’s during navigating

If you realize in the last moment that you miss a turn, don’t make rush movements and try to catch it. It’s always better to have a small detour rather than taking a risk of an accident.

7 Tips on being the perfect car passenger !

Unlike what you might think, you don’t become a passenger in a car once you’re sitting inside, but as soon as you open the door to sit down. Even if the passenger is under the responsibility of the driver, he has duties to fulfill.

1. Make sure that all interactions with the driver are considerate and not distracting. 

2. Don’t talk too loudly or putting music on the radio too loud it can distract the driver and possibly cause an accident.

3. Be cautious – wear your seat belt.

Reminder: The non-wearing of the seat belt for a passenger is punishable by a penalty of 135 euros. If the offender is of legal age, he/she will have to pay the fine; for an underage person, the driver will pay (with no points deducted).

4. Don’t wait for the driver to tell you to put it on or refuse to put it on when asked.

5. Don’t stress the driver by starting arguments or giving advice on how to driver

6. Co-pilot with respect and consideration. Warn the driver when navigating on the road, however, make sure that you do not warn the driver about unnecessary things. Your warning might take away attention from actually more important events on the road.

7. The entry and exit of a passenger must be done in optimal safety conditions. The greatest care must, therefore, be taken when opening the door so as not to obstruct traffic on the road.

Even if the driver has the most responsibility, the passenger also has a part to play when it comes to safety in the car: making sure that the driver is in the best conditions for a safe and enjoyable journey!