alon sabi
Published in

alon sabi

Powerful BI Dashboards in 15 Minutes or Less Using Docker and Metabase with NGINX and a free signed SSL

Dashboard

Background

Ever wanted to create beautiful dashboards to present your data in a meaningful manner, only to find that it costs an arm and a leg?

That’s what happened to me until a colleague introduced me to Metabase. Metabase is an easy, open source way for everyone in your company to ask questions and learn from data. It provides access to many types of databases out of the box, including MySQL, Postgresql, Mongo DB, Presto, SQL Server (and many others).

This blog will guide you through installing Metabase on the hardware you own or lease in the cloud. The process is quick and painless because of the use of Docker. Should you choose to take this mission, upon completion, you will have a running Metabase server with your custom domain with free SSL from Let’s Encrypt, using NGINX as a proxy server to allow for SSL connections.

I tested this setup on Amazon Linux 2 and Ubuntu 20.04 on AWS instances, but it should work with any Linux distribution running on Intel X86–64 architecture. I tried to run it on an Apple Silicon Mac without success (with both ARM and Intel containers). Metabase gets ‘stuck’ loading). Let me know if you can make it work 😀

This guide will not cover starting or installing a Linux server, setting up DNS with your domain, or how to install Docker and GIT on the server. There are plenty of guides for those, and it’s outside of the scope of this post. Instead, I assume you have a Linux machine running with Docker, docker-compose, and GIT installed, with your domain pointing to the server (make sure that ports 80 and 443 are accessible).

Some links for how to get going with Linux and Docker (Ubuntu in this case):

https://ubuntu.com/tutorials/install-ubuntu-desktop#1-overview
https://docs.docker.com/engine/install/ubuntu/
https://docs.docker.com/compose/install/
https://docs.docker.com/engine/install/linux-postinstall/

Note: The setup uses Port 80 to auto-generate a signed SSL, while port 443 is for accessing Metabase once it all runs.

If you have no clue how to set up DNS or get your domain, you can install NGROK or Tunneltodev. Regardless, please do us all a favour and access your Metabase server only over an SSL connection (if you value your data) unless you use Metabase in an internal network.

If you are utterly clueless about running servers or don’t mind the cost, you can skip this guide and pay for an instance to run on the Metabase servers.

Hardware requirements

You will need a Server with at least 1GB of RAM (AWS Lightsail or an EC2 instance will do nicely for that), although more is always better. The script limits the container’s memory usage to 768MB, but if you have more RAM, do adjust it for better performance (docker-composefile, change memory_limitline to suit your needs).

Software Requirements

  • Intel X86–64 based operating system
  • Docker and docker-compose installed
  • Git

To get started

  1. Log in to your Linux server, and open a terminal window.
  2. Run the following command:
git clone https://github.com/asabi/metabase.git

3. Change the directory to the folder cd metabase

4. Run ./start.sh

5. Confirm that the docker containers started successfully:

docker ps

That should show you something similar to:

6. At this point you should be able to access the Metabase server on port 3000. You can stop here if you run Metabase in an internal network or locally on your computer.

Backing up your Metabase

Once Metabase runs, you will find the database settings files in the metabase.db folder. Backing those files up will allow you to restore your server if the unthinkable happens.

I recommend using server snapshots if you use an AWS-based server; that’s the easiest way to get up and running quickly.

Setting Up SSL With Let’s Encrypt

1. Update the renew_ssl.sh script (this is optional if you don’t use a custom domain):

Change the line:

domains=("subdomain1.mydomain.com" "subdomain2.mydomain.com")

To your Metabase DNS name. For example:

domains=("metabase.mydomain.com")

2. Run the SSL renewal script ./renew_ssl.sh

3. Open a browser, and navigate to your new server:

https://metabase.mydomain.com

Note: You may need to wait a few seconds before Metabase is registered with Nginx (it can take 20 seconds or so for the Metabase engine to start.

Auto-renew the SSL certificate

Let’s Encrypt SSL certificates expire every three months. You can set up an automatic script to remove the need to maintain it.

  1. run the command crontab -e

2. Add the following line (one line, replace the /path/ with the location to where you cloned the repo into:

30 03 01 Sep,Nov,Jan,Mar,May,Jul * /path/metabase/renew_ssl.sh & > /dev/null

This 👆will renew the SSL every two months.

3. Save, and run crontab -l to confirm the change worked.

Thank you

Thank you for reading. I hope that this short blog helped you.

--

--

--

Alon Sabi’s Publication

Recommended from Medium

Flutter Case Study: Multiple Navigators with BottomNavigationBar

Microsoft 365 app — See what kind of apps can be built

“It seemed like a good idea at the time”

Old Compaq all-in-one computer from mid-1990s

Machine learning on Docker-Salary Predictor

🎮Play now!

The Planet of Animals — Space Race — 5 Million PTATs Are Ready To Go!

Bringing the scene to life — using materials and textures in Unity3D

Explore Go sync.Pool as Cache

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alon Sabi

Alon Sabi

More from Medium

Build a Tool for Data Analysis — Data Visualizations

Tableau Dashboard Version Management with Git

Dynamic Performance Analytics

Hex Latest and Greatest: May 2021 — SQL IDE, Chart Cell, Scheduling, and more!