From e96b2fe220b152b0a9aa43b81152c7f6fadbb45f Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Mon, 29 Sep 2025 22:26:43 +0100 Subject: [PATCH 01/11] Add Swetrix service --- public/svgs/swetrix.svg | 8 ++ templates/compose/swetrix.yaml | 165 +++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 public/svgs/swetrix.svg create mode 100644 templates/compose/swetrix.yaml diff --git a/public/svgs/swetrix.svg b/public/svgs/swetrix.svg new file mode 100644 index 000000000..8bb5bfdfa --- /dev/null +++ b/public/svgs/swetrix.svg @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml new file mode 100644 index 000000000..756a96839 --- /dev/null +++ b/templates/compose/swetrix.yaml @@ -0,0 +1,165 @@ +# documentation: https://docs.swetrix.com/selfhosting/how-to +# slogan: Privacy-friendly and cookieless European web analytics alternative to Google Analytics. +# category: analytics +# tags: analytics,privacy,monitoring,open-source,clickhouse,redis +# logo: svgs/swetrix.svg +# port: 3000 + +services: + swetrix: + image: swetrix/swetrix-fe:v4.0.2 + restart: always + depends_on: + - swetrix-api + environment: + # Required - public URL of the API service (e.g. https://swetrix-api.example.com) + - API_URL=${API_URL:?} + healthcheck: + test: + - CMD-SHELL + - wget --no-verbose --tries=1 --spider http://localhost:3000/ping || exit 1 + interval: 30s + start_period: 15s + + swetrix-api: + image: swetrix/swetrix-api:v4.0.2 + restart: always + environment: + # Required + - SECRET_KEY_BASE=${SECRET_KEY_BASE:?} + + # Optional + - DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-false} + - IP_GEOLOCATION_DB_PATH=${IP_GEOLOCATION_DB_PATH:-} + - DEBUG_MODE=${DEBUG_MODE:-false} + - CLOUDFLARE_PROXY_ENABLED=${CLOUDFLARE_PROXY_ENABLED:-false} + + # SMTP (optional) + - SMTP_HOST=${SMTP_HOST:-} + - SMTP_PORT=${SMTP_PORT:-} + - SMTP_USER=${SMTP_USER:-} + - SMTP_PASSWORD=${SMTP_PASSWORD:-} + - FROM_EMAIL=${FROM_EMAIL:-} + - SMTP_MOCK=${SMTP_MOCK:-false} + + # OIDC (optional) + - OIDC_ENABLED=${OIDC_ENABLED:-false} + - OIDC_ONLY_AUTH=${OIDC_ONLY_AUTH:-false} + - OIDC_DISCOVERY_URL=${OIDC_DISCOVERY_URL:-} + - OIDC_CLIENT_ID=${OIDC_CLIENT_ID:-} + - OIDC_CLIENT_SECRET=${OIDC_CLIENT_SECRET:-} + + # Required service endpoints + - REDIS_HOST=redis + - CLICKHOUSE_HOST=http://clickhouse + - CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-} + depends_on: + redis: + condition: service_healthy + clickhouse: + condition: service_healthy + healthcheck: + test: + - CMD-SHELL + - wget --no-verbose --tries=1 --spider http://localhost:5005/ping || exit 1 + interval: 30s + start_period: 15s + + redis: + image: redis:8.2-alpine + restart: always + environment: + - REDIS_PORT=${REDIS_PORT:-6379} + - REDIS_USER=${REDIS_USER:-default} + - REDIS_PASSWORD=${REDIS_PASSWORD:-} + healthcheck: + test: + - CMD-SHELL + - redis-cli ping | grep PONG + interval: 30s + start_period: 1m + + clickhouse: + image: clickhouse/clickhouse-server:24.10-alpine + restart: always + environment: + - CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE:-analytics} + - CLICKHOUSE_USER=${CLICKHOUSE_USER:-default} + - CLICKHOUSE_PORT=${CLICKHOUSE_PORT:-8123} + - CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-} + healthcheck: + test: + - CMD-SHELL + - wget --no-verbose --tries=1 -O - http://127.0.0.1:8123/ping || exit 1 + interval: 30s + start_period: 1m + cap_add: + - SYS_NICE + volumes: + # Persistent storage for ClickHouse + - swetrix-events-data:/var/lib/clickhouse + + # Disable logging + - type: bind + source: ./disable-user-logging.xml + target: /etc/clickhouse-server/users.d/disable-user-logging.xml + read_only: true + content: | + + + + 0 + 0 + + + + - type: bind + source: ./reduce-logs.xml + target: /etc/clickhouse-server/config.d/reduce-logs.xml + read_only: true + content: | + + + warning + true + + + + + + + + + + + + # Reduce RAM usage + - type: bind + source: ./preserve-ram-config.xml + target: /etc/clickhouse-server/config.d/preserve-ram-config.xml + read_only: true + content: | + + 536870912 + 1 + + - type: bind + source: ./preserve-ram-user.xml + target: /etc/clickhouse-server/users.d/preserve-ram-user.xml + read_only: true + content: | + + + + 2048 + 1 + 0 + 0 + + + + + ulimits: + nofile: + soft: 262144 + hard: 262144 From 8745054adfe9ba7724efdabbfb692bd890bb299f Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Wed, 1 Oct 2025 00:00:06 +0100 Subject: [PATCH 02/11] add timeout / retries to healthchecks --- templates/compose/swetrix.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index 756a96839..2482ac5e9 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -18,6 +18,8 @@ services: test: - CMD-SHELL - wget --no-verbose --tries=1 --spider http://localhost:3000/ping || exit 1 + timeout: 5s + retries: 10 interval: 30s start_period: 15s @@ -62,6 +64,8 @@ services: test: - CMD-SHELL - wget --no-verbose --tries=1 --spider http://localhost:5005/ping || exit 1 + timeout: 5s + retries: 10 interval: 30s start_period: 15s @@ -76,6 +80,8 @@ services: test: - CMD-SHELL - redis-cli ping | grep PONG + timeout: 5s + retries: 10 interval: 30s start_period: 1m @@ -91,6 +97,8 @@ services: test: - CMD-SHELL - wget --no-verbose --tries=1 -O - http://127.0.0.1:8123/ping || exit 1 + timeout: 5s + retries: 10 interval: 30s start_period: 1m cap_add: From 8ef759ff0a00f95803cf230751daa51b7a6b710f Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Wed, 1 Oct 2025 00:01:02 +0100 Subject: [PATCH 03/11] Use magic variable for Clickhouse password --- templates/compose/swetrix.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index 2482ac5e9..035d96a31 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -54,7 +54,7 @@ services: # Required service endpoints - REDIS_HOST=redis - CLICKHOUSE_HOST=http://clickhouse - - CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-} + - CLICKHOUSE_PASSWORD=$SERVICE_PASSWORD_CLICKHOUSE depends_on: redis: condition: service_healthy @@ -92,7 +92,7 @@ services: - CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE:-analytics} - CLICKHOUSE_USER=${CLICKHOUSE_USER:-default} - CLICKHOUSE_PORT=${CLICKHOUSE_PORT:-8123} - - CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-} + - CLICKHOUSE_PASSWORD=$SERVICE_PASSWORD_CLICKHOUSE healthcheck: test: - CMD-SHELL From 0a35594508d246509cc843284b4e8a6ffbf59206 Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Wed, 1 Oct 2025 00:02:29 +0100 Subject: [PATCH 04/11] Use magic variable for Redis password --- templates/compose/swetrix.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index 035d96a31..60f523a57 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -55,6 +55,7 @@ services: - REDIS_HOST=redis - CLICKHOUSE_HOST=http://clickhouse - CLICKHOUSE_PASSWORD=$SERVICE_PASSWORD_CLICKHOUSE + - REDIS_PASSWORD=$SERVICE_PASSWORD_REDIS depends_on: redis: condition: service_healthy @@ -75,7 +76,7 @@ services: environment: - REDIS_PORT=${REDIS_PORT:-6379} - REDIS_USER=${REDIS_USER:-default} - - REDIS_PASSWORD=${REDIS_PASSWORD:-} + - REDIS_PASSWORD=$SERVICE_PASSWORD_REDIS healthcheck: test: - CMD-SHELL From 151274a1379beb227c4fbb9104112d0128366678 Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Wed, 1 Oct 2025 00:02:58 +0100 Subject: [PATCH 05/11] Remove restart: always from services --- templates/compose/swetrix.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index 60f523a57..6b6721eef 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -8,7 +8,6 @@ services: swetrix: image: swetrix/swetrix-fe:v4.0.2 - restart: always depends_on: - swetrix-api environment: @@ -25,7 +24,6 @@ services: swetrix-api: image: swetrix/swetrix-api:v4.0.2 - restart: always environment: # Required - SECRET_KEY_BASE=${SECRET_KEY_BASE:?} @@ -72,7 +70,6 @@ services: redis: image: redis:8.2-alpine - restart: always environment: - REDIS_PORT=${REDIS_PORT:-6379} - REDIS_USER=${REDIS_USER:-default} @@ -88,7 +85,6 @@ services: clickhouse: image: clickhouse/clickhouse-server:24.10-alpine - restart: always environment: - CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE:-analytics} - CLICKHOUSE_USER=${CLICKHOUSE_USER:-default} From 15a2ba57043938dde5fe7722bdc3ef32bdaf2936 Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Wed, 1 Oct 2025 00:07:55 +0100 Subject: [PATCH 06/11] Generate SECRET_KEY_BASE with magic env --- templates/compose/swetrix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index 6b6721eef..216d333b5 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -26,7 +26,7 @@ services: image: swetrix/swetrix-api:v4.0.2 environment: # Required - - SECRET_KEY_BASE=${SECRET_KEY_BASE:?} + - SECRET_KEY_BASE=$SERVICE_BASE64_64_SECRETKEYBASE # Optional - DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-false} From b289f7cbd2d1f374ae5eaafc27242c5b5987bb17 Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Wed, 1 Oct 2025 00:15:47 +0100 Subject: [PATCH 07/11] Add app URLs --- templates/compose/swetrix.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index 216d333b5..f302ae857 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -11,8 +11,8 @@ services: depends_on: - swetrix-api environment: - # Required - public URL of the API service (e.g. https://swetrix-api.example.com) - - API_URL=${API_URL:?} + - SERVICE_URL_SWETRIX_3000 + - API_URL=$SERVICE_URL_SWETRIXAPI_5005 healthcheck: test: - CMD-SHELL @@ -27,6 +27,7 @@ services: environment: # Required - SECRET_KEY_BASE=$SERVICE_BASE64_64_SECRETKEYBASE + - SERVICE_URL_SWETRIXAPI_5005 # Optional - DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-false} From ad4a733b28fffbd573a3c64ea33989c3859cffba Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Sun, 5 Oct 2025 01:19:54 +0100 Subject: [PATCH 08/11] rm 5005 port --- templates/compose/swetrix.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index f302ae857..2089d497a 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -12,7 +12,7 @@ services: - swetrix-api environment: - SERVICE_URL_SWETRIX_3000 - - API_URL=$SERVICE_URL_SWETRIXAPI_5005 + - API_URL=$SERVICE_URL_SWETRIXAPI healthcheck: test: - CMD-SHELL @@ -27,7 +27,7 @@ services: environment: # Required - SECRET_KEY_BASE=$SERVICE_BASE64_64_SECRETKEYBASE - - SERVICE_URL_SWETRIXAPI_5005 + - SERVICE_URL_SWETRIXAPI # Optional - DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-false} From 62134aef6586614a87b3d0cd97115c267e20143d Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Tue, 7 Oct 2025 23:19:58 +0100 Subject: [PATCH 09/11] Bump Swetrix to v4.0.3 --- templates/compose/swetrix.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index 2089d497a..79658db2d 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -7,7 +7,7 @@ services: swetrix: - image: swetrix/swetrix-fe:v4.0.2 + image: swetrix/swetrix-fe:v4.0.3 depends_on: - swetrix-api environment: @@ -23,7 +23,7 @@ services: start_period: 15s swetrix-api: - image: swetrix/swetrix-api:v4.0.2 + image: swetrix/swetrix-api:v4.0.3 environment: # Required - SECRET_KEY_BASE=$SERVICE_BASE64_64_SECRETKEYBASE From d16b6e93780782ad26875655627c80a662758fa3 Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Fri, 10 Oct 2025 01:40:53 +0100 Subject: [PATCH 10/11] Bump Swetrix base version to v4.0.4 --- templates/compose/swetrix.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index 79658db2d..f6d4d919a 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -7,7 +7,7 @@ services: swetrix: - image: swetrix/swetrix-fe:v4.0.3 + image: swetrix/swetrix-fe:v4.0.4 depends_on: - swetrix-api environment: @@ -23,7 +23,7 @@ services: start_period: 15s swetrix-api: - image: swetrix/swetrix-api:v4.0.3 + image: swetrix/swetrix-api:v4.0.4 environment: # Required - SECRET_KEY_BASE=$SERVICE_BASE64_64_SECRETKEYBASE From ccdbf95a16ad38ea165d4e41cc0b51b40a2d5991 Mon Sep 17 00:00:00 2001 From: Blue Mouse Date: Sat, 11 Oct 2025 21:48:53 +0100 Subject: [PATCH 11/11] Bump version to v4.0.5 --- templates/compose/swetrix.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/compose/swetrix.yaml b/templates/compose/swetrix.yaml index f6d4d919a..850f2d00b 100644 --- a/templates/compose/swetrix.yaml +++ b/templates/compose/swetrix.yaml @@ -7,7 +7,7 @@ services: swetrix: - image: swetrix/swetrix-fe:v4.0.4 + image: swetrix/swetrix-fe:v4.0.5 depends_on: - swetrix-api environment: @@ -23,7 +23,7 @@ services: start_period: 15s swetrix-api: - image: swetrix/swetrix-api:v4.0.4 + image: swetrix/swetrix-api:v4.0.5 environment: # Required - SECRET_KEY_BASE=$SERVICE_BASE64_64_SECRETKEYBASE