diff --git a/blueprints/flarepanel/docker-compose.yml b/blueprints/flarepanel/docker-compose.yml new file mode 100644 index 000000000..c7c884868 --- /dev/null +++ b/blueprints/flarepanel/docker-compose.yml @@ -0,0 +1,138 @@ +# FlarePanel: open-source web and product analytics. +# One `app` container runs the API and background jobs (ROLE=all), so the +# SQLite metadata file has a single writer. ClickHouse holds events, Redis the +# buffers and queues, Redpanda the event stream. `migrate` applies database +# changes before the app starts, on every deploy. + +x-app-env: &app-env + NODE_ENV: production + SELF_HOSTED: "true" + DATABASE_URL: file:/data/flarepanel.db + CLICKHOUSE_URL: http://clickhouse:8123/flarepanel + REDIS_URL: redis://redis:6379 + KAFKA_BROKERS: redpanda:9092 + API_URL: ${API_URL} + DASHBOARD_URL: ${DASHBOARD_URL} + COOKIE_SECRET: ${COOKIE_SECRET} + ENCRYPTION_KEY: ${ENCRYPTION_KEY} + TRUSTED_IP_HEADER_ORDER: x-forwarded-for + ALLOW_REGISTRATION: ${ALLOW_REGISTRATION} + ALLOW_INVITATION: "true" + SMTP_HOST: ${SMTP_HOST} + SMTP_PORT: ${SMTP_PORT} + SMTP_USER: ${SMTP_USER} + SMTP_PASS: ${SMTP_PASS} + EMAIL_SENDER: ${EMAIL_SENDER} + +services: + redis: + image: redis:7.2.5-alpine + restart: unless-stopped + command: ["redis-server", "--maxmemory-policy", "noeviction", "--appendonly", "yes"] + volumes: + - redis-data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 5s + timeout: 3s + retries: 20 + + clickhouse: + image: clickhouse/clickhouse-server:26.1.3.52 + restart: unless-stopped + environment: + CLICKHOUSE_DB: flarepanel + CLICKHOUSE_SKIP_USER_SETUP: 1 + ulimits: + nofile: + soft: 262144 + hard: 262144 + volumes: + - clickhouse-data:/var/lib/clickhouse + - ../files/clickhouse_config:/etc/clickhouse-server/config.d + - ../files/clickhouse_users:/etc/clickhouse-server/users.d + healthcheck: + test: ["CMD-SHELL", "clickhouse-client -q 'SELECT 1'"] + interval: 5s + timeout: 3s + retries: 30 + + redpanda: + image: redpandadata/redpanda:v25.1.4 + restart: unless-stopped + command: + - redpanda + - start + - --kafka-addr=internal://0.0.0.0:9092 + - --advertise-kafka-addr=internal://redpanda:9092 + - --rpc-addr=0.0.0.0:33145 + - --advertise-rpc-addr=redpanda:33145 + - --smp=1 + - --memory=1G + - --mode=dev-container + - --default-log-level=warn + volumes: + - redpanda-data:/var/lib/redpanda/data + - ../files/redpanda/bootstrap.yaml:/etc/redpanda/.bootstrap.yaml:ro + healthcheck: + test: ["CMD-SHELL", "rpk cluster health -X admin.hosts=localhost:9644 | grep -q 'Healthy:.*true'"] + interval: 5s + timeout: 3s + retries: 30 + + migrate: + image: ghcr.io/flarepanel-dev/flarepanel-api:1.0.0 + restart: "no" + environment: *app-env + working_dir: /app/packages/db + command: ["sh", "-c", "bun ./scripts/migrate-sqlite.ts && bun ./scripts/migrate-code.ts"] + volumes: + - app-data:/data + depends_on: + clickhouse: + condition: service_healthy + + app: + image: ghcr.io/flarepanel-dev/flarepanel-api:1.0.0 + restart: unless-stopped + environment: + <<: *app-env + ROLE: all + volumes: + - app-data:/data + expose: + - 3000 + depends_on: + migrate: + condition: service_completed_successfully + redis: + condition: service_healthy + redpanda: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -fsS http://localhost:3000/healthcheck >/dev/null"] + interval: 10s + timeout: 5s + retries: 12 + + dashboard: + image: ghcr.io/flarepanel-dev/flarepanel-dashboard:1.0.0 + restart: unless-stopped + environment: + NODE_ENV: production + SELF_HOSTED: "true" + API_URL: ${API_URL} + # The dashboard's server reaches the API inside the compose network. + API_URL_SSR: http://app:3000 + DASHBOARD_URL: ${DASHBOARD_URL} + expose: + - 3000 + depends_on: + app: + condition: service_healthy + +volumes: + app-data: + redis-data: + clickhouse-data: + redpanda-data: diff --git a/blueprints/flarepanel/logo.svg b/blueprints/flarepanel/logo.svg new file mode 100644 index 000000000..b37d2cd70 --- /dev/null +++ b/blueprints/flarepanel/logo.svg @@ -0,0 +1 @@ + diff --git a/blueprints/flarepanel/meta.json b/blueprints/flarepanel/meta.json new file mode 100644 index 000000000..bd98435ee --- /dev/null +++ b/blueprints/flarepanel/meta.json @@ -0,0 +1,16 @@ +{ + "id": "flarepanel", + "name": "FlarePanel", + "version": "1.0.0", + "description": "Open-source web and product analytics: realtime, funnels, retention, session replay, AI crawler tracking and an AI chat for your data. No cookies.", + "logo": "logo.svg", + "links": { + "github": "https://github.com/flarepanel-dev/flarepanel", + "website": "https://flarepanel.dev/", + "docs": "https://docs.flarepanel.dev/self-hosting/server" + }, + "tags": [ + "analytics", + "self-hosted" + ] +} diff --git a/blueprints/flarepanel/template.toml b/blueprints/flarepanel/template.toml new file mode 100644 index 000000000..981cc2877 --- /dev/null +++ b/blueprints/flarepanel/template.toml @@ -0,0 +1,107 @@ +[variables] +main_domain = "${domain}" +cookie_secret = "${hash:32}" +encryption_key = "${hash:32}" + +[config] +# The dashboard on the domain, the API under /api on the same domain. +[[config.domains]] +serviceName = "dashboard" +port = 3000 +host = "${main_domain}" + +[[config.domains]] +serviceName = "app" +port = 3000 +host = "${main_domain}" +path = "/api" +stripPath = true + +[config.env] +DASHBOARD_URL = "http://${main_domain}" +API_URL = "http://${main_domain}/api" +COOKIE_SECRET = "${cookie_secret}" +# Keep a copy: stored AI and integration keys cannot be read without it. +ENCRYPTION_KEY = "${encryption_key}" +# The first account can always sign up; after that only invited people, +# unless this is "true". +ALLOW_REGISTRATION = "false" +# Optional: SMTP for verification, invitation and password-reset emails. +SMTP_HOST = "" +SMTP_PORT = "" +SMTP_USER = "" +SMTP_PASS = "" +EMAIL_SENDER = "" + +[[config.mounts]] +filePath = "./clickhouse_config/flarepanel.xml" +content = """ + + + warning + true + + + + + + 10 + + + + + + + + + + + + 0.0.0.0 + 0.0.0.0 + clickhouse + + + + 1 + replica1 + flarepanel_cluster + + +""" + +[[config.mounts]] +filePath = "./clickhouse_users/flarepanel.xml" +content = """ + + + + 0 + 0 + + + + + + + + ::/0 + + default + default + + + +""" + +[[config.mounts]] +filePath = "./redpanda/bootstrap.yaml" +content = """ +default_topic_partitions: 24 +default_topic_replications: 1 +auto_create_topics_enabled: true +log_compression_type: lz4 +log_retention_ms: 172800000 +"""