From f384c7b90653434240e4d44b7c6844fe44aac34e Mon Sep 17 00:00:00 2001 From: James Loh Date: Thu, 3 Jul 2025 17:56:11 +1000 Subject: [PATCH] TB: Move configuration to UI instead of env - TB can now be toggled via the UI and setting it via env variables means the setting can never be toggled on/off properly - Doing it this way lets users control things more --- .env.example | 30 +++++++++++++++++++++--------- TINYBIRD.md | 3 ++- compose.yml | 5 ++--- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index 569b653..67cad11 100644 --- a/.env.example +++ b/.env.example @@ -1,21 +1,33 @@ +# Use the below flags to enable the Analytics or ActivityPub containers as well +# Note: You must set ENABLE_DEVELOPER_EXPERIMENTS to `true` when enabling either profile below # COMPOSE_PROFILES=analytics,activitypub # Which Ghost version to run GHOST_VERSION=5-alpine +# Public domain Ghost is going to run on DOMAIN=example.com +# Database settings +DATABASE_ROOT_PASSWORD=reallysecurerootpassword +DATABASE_USER=optionalusername +DATABASE_PASSWORD=ghostpassword + +# Developer Experiences must be enabled for +# both Traffic Analytics and ActivityPub +ENABLE_DEVELOPER_EXPERIMENTS=false + +# Developer Experiments must be enabled above +ENABLE_ACTIVITYPUB=false + +# Tinybird configuration +TINYBIRD_API_URL=https://api.tinybird.co +TINYBIRD_TRACKER_TOKEN=p.eyJxxxxx +TINYBIRD_STATS_TOKEN=p.eyJxxxxx + +# Data locations # Location to store uploaded data UPLOAD_LOCATION=./data/ghost # Location for database data MYSQL_DATA_LOCATION=./data/mysql - -DATABASE_ROOT_PASSWORD=reallysecurerootpassword -DATABASE_USER=optionalusername -DATABASE_PASSWORD=ghostpassword - -# Tinybird configuration for analytics -TINYBIRD_API_URL=https://api.tinybird.co -TINYBIRD_TRACKER_TOKEN=p.eyJxxxxx -TINYBIRD_STATS_TOKEN=p.eyJxxxxx diff --git a/TINYBIRD.md b/TINYBIRD.md index a9a8e70..fd9769f 100644 --- a/TINYBIRD.md +++ b/TINYBIRD.md @@ -11,5 +11,6 @@ Steps: 1. Using the UI link from the previous step, open your workspace and click on *Tokens* in the left hand menu 1. Copy your Tinybird `stats_page` token and add it to your `.env` file as `TINYBIRD_STATS_TOKEN` 1. Copy your Tinybird `tracker` token and add it to your `.env` file as `TINYBIRD_TRACKER_TOKEN` -1. Run `docker compose --profile=analytics up -d` to start all services in the background. You can also set `COMPOSE_PROFILES=analytics` in your `.env` file to automatically include the `analytics` profile when running `docker compose` commands. +1. Run `docker compose --profile=analytics up -d` to start all services in the background +1. Set `COMPOSE_PROFILES=analytics` in your `.env` file to automatically include the `analytics` profile when running `docker compose` commands 1. At this point, everything should be working. You can test it's working by visiting your site's homepage, then checking the Stats page in Ghost Admin — you should see a view recorded. diff --git a/compose.yml b/compose.yml index 25c61f3..b02f2d9 100644 --- a/compose.yml +++ b/compose.yml @@ -33,9 +33,8 @@ services: database__connection__user: ${DATABASE_USER:-ghost} database__connection__password: ${DATABASE_PASSWORD:?DATABASE_PASSWORD environment variable is required} database__connection__database: ghost - enableDeveloperExperiments: true - labs__trafficAnalytics: true - labs__ActivityPub: true + enableDeveloperExperiments: ${ENABLE_DEVELOPER_EXPERIMENTS:-false} + labs__ActivityPub: ${ENABLE_ACTIVITYPUB:-false} tinybird__tracker__endpoint: https://${DOMAIN:?DOMAIN environment variable is required}/.ghost/analytics/tb/web_analytics tinybird__tracker__datasource: analytics_events tinybird__tracker__token: ${TINYBIRD_TRACKER_TOKEN:-}