From 7b4bea0645794011b34447f41934a5f702a02d41 Mon Sep 17 00:00:00 2001
From: FarisZR <35614734+FarisZR@users.noreply.github.com>
Date: Mon, 21 Oct 2024 21:44:06 +0200
Subject: [PATCH] Add plausible
---
.github/workflows/plausible.yml | 58 +++++++++++++++++++++++
plausible/clickhouse-config.xml | 23 +++++++++
plausible/clickhouse-user-config.xml | 8 ++++
plausible/docker-compose.yml | 70 ++++++++++++++++++++++++++++
4 files changed, 159 insertions(+)
create mode 100644 .github/workflows/plausible.yml
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/.github/workflows/plausible.yml b/.github/workflows/plausible.yml
new file mode 100644
index 0000000..d506d7e
--- /dev/null
+++ b/.github/workflows/plausible.yml
@@ -0,0 +1,58 @@
+name: deploy-plausible
+
+on:
+ push:
+ paths:
+ - '.github/workflows/plausible.yml'
+ - 'plausible/**'
+ branches: [main]
+ workflow_dispatch:
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ environment:
+ name: Plausible
+ url: https://pa.aosus.org
+ steps:
+ - name: checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Tailscale
+ uses: tailscale/github-action@7a0b30ed3517c2244d1330e39467b95f067a33bd
+ with:
+ oauth-client-id: ${{ secrets.TAILSCALE_CLIENT_ID }}
+ oauth-secret: ${{ secrets.TAILSCALE_SECRET }}
+ tags: tag:deploy-ci
+ hostname: Github-actions
+ version: ${{ vars.TAILSCALE_VERSION }}
+
+ - name: Add secrets to compose
+ env:
+ SECRET_KEY_BASE: ${{ secrets.plausible_secret_key_base }}
+ TOTP_VAULT_KEY: ${{ secrets.plausible_totp_vault_key }}
+ SMTP_USER_PWD: ${{ secrets.plausible_smtp_user_pwd }}
+ GOOGLE_CLIENT_ID: ${{ secrets.plausible_google_client_id }}
+ GOOGLE_CLIENT_SECRET: ${{ secrets.plausible_google_client_secret }}
+ POSTGRES_PASSWORD: ${{ secrets.plausible_postgres_password }}
+ MAXMIND_LICENSE_KEY: ${{ secrets.plausible_maxmind_license_key }}
+ run: |
+ sed -i "s|(plausible_secret_key_base)|$SECRET_KEY_BASE|g" $GITHUB_WORKSPACE/plausible/docker-compose.yml
+ sed -i "s|(plausible_totp_vault_key)|$TOTP_VAULT_KEY|g" $GITHUB_WORKSPACE/plausible/docker-compose.yml
+ sed -i "s|(plausible_smtp_user_pwd)|$SMTP_USER_PWD|g" $GITHUB_WORKSPACE/plausible/docker-compose.yml
+ sed -i "s|(plausible_google_client_id)|$GOOGLE_CLIENT_ID|g" $GITHUB_WORKSPACE/plausible/docker-compose.yml
+ sed -i "s|(plausible_google_client_secret)|$GOOGLE_CLIENT_SECRET|g" $GITHUB_WORKSPACE/plausible/docker-compose.yml
+ sed -i "s|(plausible_postgres_password)|$POSTGRES_PASSWORD|g" $GITHUB_WORKSPACE/plausible/docker-compose.yml
+ sed -i "s|(plausible_maxmind_license_key)|$MAXMIND_LICENSE_KEY|g" $GITHUB_WORKSPACE/plausible/docker-compose.yml
+
+ - name: Start Deployment
+ uses: FarisZR/docker-compose-gitops-action@v1.0.1
+ with:
+ remote_docker_host: ${{ secrets.server_address }}
+ tailscale_ssh: true # no need for manual private and public keys
+ compose_file_path: plausible/docker-compose.yml
+ args: -p plausible up -d --remove-orphans
+ upload_directory: true
+ docker_compose_directory: plausible
\ No newline at end of file
diff --git a/plausible/clickhouse-config.xml b/plausible/clickhouse-config.xml
new file mode 100644
index 0000000..2f1afb0
--- /dev/null
+++ b/plausible/clickhouse-config.xml
@@ -0,0 +1,23 @@
+
+
+ warning
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plausible/clickhouse-user-config.xml b/plausible/clickhouse-user-config.xml
new file mode 100644
index 0000000..ae6a6b9
--- /dev/null
+++ b/plausible/clickhouse-user-config.xml
@@ -0,0 +1,8 @@
+
+
+
+ 0
+ 0
+
+
+
\ No newline at end of file
diff --git a/plausible/docker-compose.yml b/plausible/docker-compose.yml
new file mode 100644
index 0000000..e4a826d
--- /dev/null
+++ b/plausible/docker-compose.yml
@@ -0,0 +1,70 @@
+networks:
+ default:
+ enable_ipv6: true
+ web:
+ external: true
+
+services:
+ plausible_db:
+ restart: unless-stopped
+ image: postgres:16.4-alpine@sha256:d898b0b78a2627cb4ee63464a14efc9d296884f1b28c841b0ab7d7c42f1fffdf
+ volumes:
+ - /home/aosus/plausible/postgres:/var/lib/postgresql/data
+ environment:
+ - POSTGRES_PASSWORD=(plausible_postgres_password)
+
+ plausible_events_db:
+ restart: unless-stopped
+ image: clickhouse/clickhouse-server:24.3.3.102-alpine
+ volumes:
+ - /home/aosus/plausible/event-data:/var/lib/clickhouse
+ configs:
+ - source: clickhouse-config
+ target: /etc/clickhouse-server/config.d/logging.xml
+ - source: clickhouse-user-config
+ target: /etc/clickhouse-server/users.d/logging.xml
+ ulimits:
+ nofile:
+ soft: 262144
+ hard: 262144
+
+ plausible:
+ restart: unless-stopped
+ image: ghcr.io/plausible/community-edition:v2.1.4@sha256:59ffee982deb849a2749eef206005e475e688d59fa053858d75420d95cddb8e8
+ container_name: plausible
+ command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
+ expose:
+ - 8000
+ depends_on:
+ - plausible_db
+ - plausible_events_db
+ # ports:
+ # - 8004:8000
+ environment:
+ - BASE_URL=https://pa.aosus.org
+ - DISALBLE_REGISTRATION=true
+ - MAILER_EMAIL=plausible@services.aosus.org
+ - SMTP_HOST_ADDR=smtp.eu.mailgun.org
+ - SMTP_HOST_PORT=587
+ - SMTP_USER_NAME=plausible@services.aosus.org
+ - SECRET_KEY_BASE=(plausible_secret_key_base)
+ - TOTP_VAULT_KEY=(plausible_totp_vault_key)
+ - SMTP_USER_PWD=(plausible_smtp_user_pwd)
+ - MAILER_ADAPTER=Bamboo.Mua
+ - GOOGLE_CLIENT_ID=(plausible_google_client_id)
+ - GOOGLE_CLIENT_SECRET=(plausible_google_client_secret)
+ - MAXMIND_LICENSE_KEY=(plausible_maxmind_license_key)
+ - MAXMIND_EDITION=GeoLite2-City
+ networks:
+ default:
+ web:
+
+volumes:
+ geoip:
+ driver: local
+
+configs:
+ clickhouse-config:
+ file: /home/aosus/plausible/clickhouse-config.xml
+ clickhouse-user-config:
+ file: /home/aosus/plausible/clickhouse-user-config.xml
\ No newline at end of file