# 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.5 depends_on: - swetrix-api environment: - SERVICE_URL_SWETRIX_3000 - API_URL=$SERVICE_URL_SWETRIXAPI healthcheck: test: - CMD-SHELL - wget --no-verbose --tries=1 --spider http://localhost:3000/ping || exit 1 timeout: 5s retries: 10 interval: 30s start_period: 15s swetrix-api: image: swetrix/swetrix-api:v4.0.5 environment: # Required - SECRET_KEY_BASE=$SERVICE_BASE64_64_SECRETKEYBASE - SERVICE_URL_SWETRIXAPI # 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=$SERVICE_PASSWORD_CLICKHOUSE - REDIS_PASSWORD=$SERVICE_PASSWORD_REDIS 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 timeout: 5s retries: 10 interval: 30s start_period: 15s redis: image: redis:8.2-alpine environment: - REDIS_PORT=${REDIS_PORT:-6379} - REDIS_USER=${REDIS_USER:-default} - REDIS_PASSWORD=$SERVICE_PASSWORD_REDIS healthcheck: test: - CMD-SHELL - redis-cli ping | grep PONG timeout: 5s retries: 10 interval: 30s start_period: 1m clickhouse: image: clickhouse/clickhouse-server:24.10-alpine environment: - CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE:-analytics} - CLICKHOUSE_USER=${CLICKHOUSE_USER:-default} - CLICKHOUSE_PORT=${CLICKHOUSE_PORT:-8123} - CLICKHOUSE_PASSWORD=$SERVICE_PASSWORD_CLICKHOUSE healthcheck: 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: - 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