How to install Metabase on a real server?


This part of the course wouldn't have been possible without the help of Lukas Winkler, thank you so much.

You may wonder why you should bother thinking about installing Metabase on a real server? Well, installing Metabase on a local server is great for a personnal use, however if your plan is to share your work and make it accessible to others, you will need to have a server in order to make those documents accessible to others. It will be as well really useful for you to access it from anywhere.

It is also raising the concen in terms of security as it means that people from the outside could technically access all your database.

Metabase can also be installed through other different options, let's see them below.

  • AWS.
  • Heroku.
  • Docker.

What is AWS?

The biggest cloud service ever. It's a big service on which you can get the machine you need or want as far as you can pay for it. Main issue here is that AWS stands for Amazon Web Services, so to say by using this solution you will lose the advantage of using Metabase because you will host your data on a GAFAM web hosting platform.

What is Heroku?

So as AWS, Heroku is a cloud service providing apps including Metabase in order to deploy it straight away. Heroku is a proprietary technology which belong to Salesforce... where high chances that data are stored on AWS. So, to me no reason to choose this solution for a deployment.

What is Docker?

Docker is a flexible way to deploy apps on your server.

As you can see from those options, only Docker is a viable option for a Free software enthousiast, so that's the option we are going to choose. The official documentation is available here:

https://www.metabase.com/docs/v0.34.2/operations-guide/running-metabase-on-docker.html

Getting started

The first step is about connecting to your server:

ssh identifier@your-ip

if you don't remember how to type that out, just enter history in order to see the last time you executed this request.

Next step is about creating a directory which will host your metabase data, so once on your server just run at root:

mkdir metabase-data

Then run:

docker run -d -p 3000:3000 \
-v ~/metabase-data:/metabase-data \
-e "MB_DB_FILE=/metabase-data/metabase.db" \
--name metabase metabase/metabase

If you are not sure that an app is using a given port, run:

netstat -tulpn

and it will give you the busy ports, for example.

If port 3000 is taken, just change the lines like this:

docker run -d -p 3001:3000 \
-v ~/metabase-data:/metabase-data \
-e "MB_DB_FILE=/metabase-data/metabase.db" \
--name metabase metabase/metabase

and it will do the job.

Ok so now, we need to have a URL is https in order to run our app. So let's run:

sudo certbot certonly -d your-domain-name

Congratulations you now have an https.

Ok, now you need to create an Apache config file in order to explain to your server about the domain name you are creating.

So go within /etc/apache2/sites-available/ and create a file such as, ending in .conf:

<IfModule mod_ssl.c>
<VirtualHost *:443>
   ServerName your-domain.com
   ProxyPass / http://localhost:3001/
   ProxyPreserveHost On
   ProxyRequests off
   ProxyPassReverse / http://localhost:3001/
SSLCertificateFile /etc/letsencrypt/live/your-domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your-domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

and you need to activate it with:

sudo a2ensite your-file.conf

then you need to restart your server with:

sudo systemctl reload apache2

and you should be now good to go when you type the url of your domain in the address bar:

The setup GUI page of Metabase

Next steps are just about mentioning the credentials you would like to use to connect to Metabase and you are good to go.

Last modified: Monday, 9 March 2020, 3:02 PM