Self hosting Plausible with Caprover

Reading time:   2 min

self-hosting-plausible-with-caprover

Plausible Analytics is a simple and privacy-friendly alternative to Google Analytics.

They offer a free Plausible Analytics Self-Hosted, that it’s exactly the same code as their Cloud solution, but you have to install on your server.

As a fan of Caprover, that I use everyday to manage my web applications, and after looking at the official Caprover repository for one-click apps, I found that Plausible was missing, so I decided to write the template.

On their offical repository there is a docker-compose.yml file that I used as starting point to transform in a one-click Caprover app, but the GeoLite2 database created by MaxMind for enriching analytics data with visitor countries was not present.

So, looking at the self hosted guides available in their documentation, I came up with a plausible.yml template:

captainVersion: 4

services:
  $$cap_appname-mail:
    image: bytemark/smtp
    restart: always
    environment:
      RELAY_HOST: $$cap_RELAY_HOST
      RELAY_PORT: $$cap_RELAY_PORT
      RELAY_USERNAME: $$cap_RELAY_USERNAME
      RELAY_PASSWORD: $$cap_RELAY_PASSWORD
    caproverExtra:
      notExposeAsWebApp: "true"

  $$cap_appname-postgres:
    image: postgres:12-alpine
    volumes:
      - $$cap_appname-postgres-data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: plausible
      POSTGRES_PASSWORD: $$cap_POSTGRES_PASSWORD
    caproverExtra:
      notExposeAsWebApp: "true"

  $$cap_appname-clickhouse:
    image: yandex/clickhouse-server:20.8.5.45
    volumes:
      - $$cap_appname-clickhouse-data:/var/lib/clickhouse
    caproverExtra:
      notExposeAsWebApp: "true"

  $$cap_appname:
    depends_on:
      - $$cap_appname-postgres
      - $$cap_appname-clickhouse
      - $$cap_appname-mail
    environment:
      ADMIN_USER_EMAIL: $$cap_ADMIN_USER_EMAIL
      ADMIN_USER_NAME: $$cap_ADMIN_USER_NAME
      ADMIN_USER_PWD: $$cap_ADMIN_USER_PWD
      BASE_URL: http://$$cap_appname.$$cap_root_domain
      DATABASE_URL: postgres://plausible:$$cap_POSTGRES_PASSWORD@srv-captain--$$cap_appname-postgres:5432/plausible
      SECRET_KEY_BASE: $$cap_gen_random_hex(64)
      SIGNING_SALT: $$cap_gen_random_hex(24)
      DISABLE_REGISTRATION: "true"
      DISABLE_SUBSCRIPTION: "true"
    caproverExtra:
      containerHttpPort: "8000"

Simply copy and paste this template in Caprover, and you'll have a Plausible.io self hosted analytics application up and running!

Then follow their guide to add your first website, and copy the automatically generated snippet in the <head> tag of your website.

EDIT: as if today, 31/10/2020, the Plausible template is already available in the official repository. Simply search for the app inside Caprover installation:

Select an app name - can be plausible 😀 - and deploy!

Interested in a practical digital transformation roadmap?

Let us map your process, identify quick wins and build a reliable web solution for your team.

Thomas Cenni

Professional experience with a human approach

Thomas Cenni is an Electronic Engineer with more than 20 years of experience in program management and software engineering. He combines strategic product thinking with practical delivery to help companies modernize operations.

Certified SAFe 6 Agilist, entrepreneur and multicultural leader with experience in Italy, Brazil and France, fluent in English, French, Italian and Brazilian Portuguese.