Author: Roman Prytkov

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 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.

We’re Hiring – Jobs at DriveTrust

We have received an investment and currently are looking for people who are interested in working in a start-up.
The areas you could work on are:

    • Embedded Firmware
    • Computer Vision
    • Hardware
    • Linux Applications
    • Mobile Applications

In case you are interested please click the button below and submit an application!


Hardware Engineer

Responsibilities

  1. Taking part in PCB design, validation and testing
  2. Taking part in hands-on prototyping
  3. Debugging activities
  4. Procurement of selected components and prototypes.

Required Skills

  • The engineer is comfortable with using CAD tools for multi-layer PCB layout. e.g. Altium Designer, CircuitStudio or CircuitMaker
  • Using hardware debugging and analysis tools such as oscilloscope, multimeter, signal generator, logic analyzers
  • Ability to read datasheets
  • Reading and designing electronics schematics

Optional Skills

  • Knowledge of real-time systems
  • 3D modeling skills for illustration and 3D printing
  • JTAG debugging
  • Experience with memory layout and camera
  • Experience with industrial design and enclosure design


Firmware Engineer

Developing drivers and integration software between hardware devices and the operating system. The devices include communication modules, a camera, sensors, a GNSS module and potentially external coprocessors.

Responsibilities

  1. Developing and porting Linux device drivers, such as ISP driver and communication module drivers.
  2. Compiling a custom kernel
  3. Porting open-source device drivers
  4. Ensuring the Linux OS can communicate with devices in an optimal way

Required Skills

  • Fluent in C
  • Comfortable with Linux environment
  • Understanding of compilation process, computer architecture
  • Understanding of interfaces such as I2C, SPI, MIPI-CSI and similar
  • Ability to read datasheets

Optional Skills

  • Experience with ISP drivers
  • Experience with Gstreamer and V4L2 pipeline
  • Experience with OpenCL
  • Fluent in C++
  • Experience with ARM architecture and ARM Assembly
  • Experience with memory layout
  • Experience with camera interfaces
  • Knowledge about communication protocols and modules e.g. Bluetooth 4.x/5, LTE, WiFi


Application Engineer

Developing the DriveTrust application for the DriveTrust device. In terms of the application environment, the DriveTrust device can be compared to Raspberry Pi.

Responsibilities

  1. Get data from sensors and processes/threads
  2. Combine the data into metrics  e.g. three strong acceleration events in two minutes = aggressive driver
  3. Send the data to cloud over the mobile network (mobile network module configuration might be required)
  4. Second Prio: working with Wifi, Bluetooth, V2X communication

Required Skills

  • Speaks English
  • Linux native
  • Proficient in Python

Optional Skills

  • C/C++
  • Android / iOS development


Computer Vision and Data Engineer

We will have a camera and would like to detect objects in real time from the video. Objects we would like to detect are cars, pedestrians and street signs. The MVP is a camera which can accurately detect street signs and traffic lights. On top of that depending on complexity we would like to have a lane departure warning system (LDWS) and a front collision warning system (FCWS)

Responsibilities

  1. Develop / Train a neural network for detection of cars, pedestrians, traffic lights, LDWS and FCWS
  2. Optimizing the network for the constrained hardware which is used
  3. Optional: combining object detection with sensor data to improve precision, e.g. getting speed from GNSS to improve FCWS
  4. Optional: Filter Sensor Data from GNSS / accelerometer to detect certain events

Required Skills

  • Speaks English
  • OpenCV
  • Experience with object/image detection frameworks (Tensorflow, Caffe or similar)


Project Assistant

Responsibilities

  1. Administrative tasks:
    1. Procurement of hardware parts/travel booking/  basic bookkeeping
    2.  Interface to accounting with University Rennes 1
    3. Support with French legal requirements (like starting a company/opening bank account)
  2. Communication:
    1. With partners and local in Rennes(organizing meeting/events etc.)
    2. With potential customers/businesses who are interested in us
  3. Content Creation / Online Research (optional, second priority):
    1. Maintain a blog, PR, basic online marketing
    2. Business Research: Funding / Investment programs, Potential customers etc.

Required Skills

  • Speaks English and French (Preferably C1 for both languages)


Driver Evaluation

We distinguish between two categories of measurements. The “classic measurements”  corresponds to driver evaluation based on already existing technologies and which can be accomplished with GNSS and accelerometer. The new metrics developed by DriveTrust rely on the camera on DriveTrust’s real-time object detection capabilities.

Classic Driving Behaviour Evaluation

Those metrics are used by other devices already existing in the market. DriveTrust collects the following data and combines them into profiles:

  1.  Generic driving behaviour, aka the “generic profile” which consists of:
    • total distance driven and average distance driven per month
    • nighttime hours driven
    • hours driven in bad weather conditions
  2. Aggressive driving which we combine to the “aggressiveness profile” is built from the
    • number of harsh acceleration and braking events
    • strong acceleration in curve events

Innovative / New Driving Evaluation Metrics

DriveTrust is developing new driving behaviour evaluation metrics. For this purpose, we work closely with our car insurance partners. There are three main metrics categories:

  1. Reaction Time: we measure reaction time to traffic signs and traffic lights, which gives a “reaction profile” for each driver
  2. Distance to other cars: the combination of speed data from GPS and the distance estimate from the camera provides insight into the “tailgating profile” of the driver.
  3. Lane Departure: we track if the driver slowly drifts into the left or right side of the road. Hence, we generate a “drifting profile” for each driver

Example mapping of a driver behaviour based on profiles

The combination of the reaction, tailgating and drifting profiles give the possibility to evaluate drivers better than with already existing technologies.