How to Self-Host Plausible Analytics with Docker

Self-Hosting Jan 8, 2021

What is Plausible?

'Plausible is a lightweight and open-source website analytics tool. No cookies and fully compliant with GDPR, CCPA and PECR.

A simple, lightweight (< 1 KB), open source and privacy-friendly alternative that doesn't come from the adtech world.' -plausible.io

Plausible Cloud starts at $6/mo for 10k pageviews, pricing and info can be found here.

Plausible have recently provided the community with the capability to self-host using docker. Therefore I would suggest you Contribute or Sponsor with GitHub to support the development.

Live Demo

Plausible Screenshot

Install with Docker

Prerequisites:
Docker
Docker-Compose

Steps:

Take a copy of the following templates

  1. docker-compose:
version: "3.3"
services:
  mail:
    image: bytemark/smtp
    restart: always
    networks:
      default:
        ipv4_address: 10.10.10.7

  plausible_db:
    image: postgres:12
    volumes:
      - ./db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=postgres
    networks:
      default:
        ipv4_address: 10.10.10.8

  plausible_events_db:
    image: yandex/clickhouse-server:latest
    volumes:
      - ./event-data:/var/lib/clickhouse
      - ./clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
      - ./clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    networks:
      default:
        ipv4_address: 10.10.10.9

  plausible:
    image: plausible/analytics:latest
    command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    depends_on:
      - plausible_db
      - plausible_events_db
      - mail
#Optional, used with the geoip docker
#      - geoip
#    volumes:
#      - ./geoip:/geoip:ro
#    environment:
#      - GEOLITE2_COUNTRY_DB=/geoip/GeoLite2-Country.mmdb
    env_file:
      - plausible-conf.env
    networks:
      default:
        ipv4_address: 10.10.10.10

#  geoip:
#    image: maxmindinc/geoipupdate
#    environment:
#      - GEOIPUPDATE_EDITION_IDS=GeoLite2-Country
#      - GEOIPUPDATE_FREQUENCY=168 # update every 7 days
#    env_file:
#     - geoip.env
#    volumes:
#      - ./geoip:/usr/share/GeoIP


networks:
  default:
    external:
      name: dockernet
  1. plausible-conf.env:
[email protected]
ADMIN_USER_NAME=bob
ADMIN_USER_PWD=changeme
BASE_URL=https://stats.example.com:443 #Port 8000 by default without reverse proxy
SECRET_KEY_BASE="xxxxREAD INSTRUCTIONS TO CHANGExxxx"
  1. Generate SECRET_KEY_BASE with this command:
openssl rand -base64 64
  1. Optional if using the geoip docker
    geoip.env:
GEOIPUPDATE_ACCOUNT_ID=<your-account-id>
GEOIPUPDATE_LICENSE_KEY=<your-license-key>

Free MaxMind Account required https://www.maxmind.com/en/geolite2/signup

  1. Start up the dockers
    sudo docker-compose up -d

  2. Access or configure a reverse proxy the Plausible WebUI at http://10.10.10.10:8000

Plausible Self Hosting Guide: https://plausible.io/docs/self-hosting

Tags