From 59ca26156547aeed9673be1b6a001c72c5d8740f Mon Sep 17 00:00:00 2001 From: William Date: Fri, 30 Dec 2022 15:16:31 +0100 Subject: [PATCH] feat: Add Plausible stack --- plausible/.env.example | 6 +++ plausible/README.md | 15 +++++++ plausible/clickhouse-config.xml | 14 +++++++ plausible/clickhouse-user-config.xml | 8 ++++ plausible/docker-compose.yml | 59 ++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 plausible/.env.example create mode 100644 plausible/README.md create mode 100644 plausible/clickhouse-config.xml create mode 100644 plausible/clickhouse-user-config.xml create mode 100644 plausible/docker-compose.yml diff --git a/plausible/.env.example b/plausible/.env.example new file mode 100644 index 0000000..34e6c62 --- /dev/null +++ b/plausible/.env.example @@ -0,0 +1,6 @@ +PLAUSIBLE_HOST=plausible.example.org +ADMIN_USER_EMAIL=admin@example.org +ADMIN_USER_NAME=admin +ADMIN_USER_PWD=admin +BASE_URL=http://plausible.example.org +SECRET_KEY_BASE=secret diff --git a/plausible/README.md b/plausible/README.md new file mode 100644 index 0000000..d0a0538 --- /dev/null +++ b/plausible/README.md @@ -0,0 +1,15 @@ +# Plausible + +## Run + +Generate the secret app key with this command : + +```bash +openssl rand -base64 64 | tr -d '\n' ; echo +``` + + +```bash +cp .env.example .env # then edit +docker compose up -d +``` diff --git a/plausible/clickhouse-config.xml b/plausible/clickhouse-config.xml new file mode 100644 index 0000000..ddd5f1c --- /dev/null +++ b/plausible/clickhouse-config.xml @@ -0,0 +1,14 @@ + + + warning + true + + + + + + + + + + diff --git a/plausible/clickhouse-user-config.xml b/plausible/clickhouse-user-config.xml new file mode 100644 index 0000000..f795286 --- /dev/null +++ b/plausible/clickhouse-user-config.xml @@ -0,0 +1,8 @@ + + + + 0 + 0 + + + diff --git a/plausible/docker-compose.yml b/plausible/docker-compose.yml new file mode 100644 index 0000000..e9a2a27 --- /dev/null +++ b/plausible/docker-compose.yml @@ -0,0 +1,59 @@ +version: '3' + +networks: + web: + external: true + plausible: + driver: bridge + +volumes: + postgres-data: + clickhouse-data: + +services: + mail: + image: bytemark/smtp + restart: unless-stopped + + plausible_db: + image: postgres:14-alpine + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + - POSTGRES_PASSWORD=postgres + networks: + - plausible + + plausible_events_db: + image: clickhouse/clickhouse-server:22.6-alpine + restart: unless-stopped + volumes: + - clickhouse-data:/var/lib/clickhouse + - ./clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro + - ./clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro + ulimits: + nofile: + soft: 262144 + hard: 262144 + networks: + - plausible + + plausible: + image: plausible/analytics:v1.5.1 + restart: unless-stopped + 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 + env_file: + - .env + networks: + - plausible + - web + labels: + - "traefik.enable=true" + - "traefik.http.routers.grafana.entrypoints=http" + - "traefik.http.routers.grafana.rule=Host(`${PLAUSIBLE_HOST}`)" + - "traefik.http.services.grafana.loadbalancer.server.port=8000" \ No newline at end of file