From 5d61db594be1a716609e5334c276abd88f080164 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 01:46:07 +0000 Subject: [PATCH 1/6] feat: add Vercel deployment config for Ghana Council e.V. - vercel.json: configures vercel-php@0.7.2 runtime, routes all traffic through index.php, and wires DB credentials from Vercel secrets - scripts/vercel-build.php: build-time script that generates adm_my_files/config.php from environment variables with the Ghana Council NRW root path (https://www.ghanacouncil-nrw.de) and Europe/Berlin timezone pre-configured - .vercelignore: excludes Dockerfile, CI config, and demo data from the deployment bundle https://claude.ai/code/session_01XovpLEu54vubV3n1FyyGR2 --- .vercelignore | 11 +++++++ scripts/vercel-build.php | 64 ++++++++++++++++++++++++++++++++++++++++ vercel.json | 26 ++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 .vercelignore create mode 100644 scripts/vercel-build.php create mode 100644 vercel.json diff --git a/.vercelignore b/.vercelignore new file mode 100644 index 000000000..d5907970e --- /dev/null +++ b/.vercelignore @@ -0,0 +1,11 @@ +# Exclude development and build tooling +.github/ +.travis.yml +.codeclimate.yml +Dockerfile +README*.md +demo_data/ + +# Exclude test/dev files +*.test.php +*.spec.php diff --git a/scripts/vercel-build.php b/scripts/vercel-build.php new file mode 100644 index 000000000..fb11dd6e8 --- /dev/null +++ b/scripts/vercel-build.php @@ -0,0 +1,64 @@ + Date: Tue, 24 Mar 2026 01:49:46 +0000 Subject: [PATCH 2/6] refactor: consolidate Vercel config into vercel/ folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move scripts/vercel-build.php → vercel/build.php and fix config path - Update vercel.json buildCommand to reference vercel/build.php - Add vercel/README.md with deployment instructions and env var table - Add vercel/.env.example with all required credentials as placeholders (DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASS) ready to paste into Vercel project settings https://claude.ai/code/session_01XovpLEu54vubV3n1FyyGR2 --- vercel.json | 2 +- vercel/.env.example | 20 ++++++++++++ vercel/README.md | 33 ++++++++++++++++++++ scripts/vercel-build.php => vercel/build.php | 2 +- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 vercel/.env.example create mode 100644 vercel/README.md rename scripts/vercel-build.php => vercel/build.php (97%) diff --git a/vercel.json b/vercel.json index 41196001b..d1cac8acd 100644 --- a/vercel.json +++ b/vercel.json @@ -1,6 +1,6 @@ { "version": 2, - "buildCommand": "composer install --no-dev --optimize-autoloader && php scripts/vercel-build.php", + "buildCommand": "composer install --no-dev --optimize-autoloader && php vercel/build.php", "functions": { "**/*.php": { "runtime": "vercel-php@0.7.2" diff --git a/vercel/.env.example b/vercel/.env.example new file mode 100644 index 000000000..881a6abcb --- /dev/null +++ b/vercel/.env.example @@ -0,0 +1,20 @@ +# Vercel Environment Variables — Ghana Council e.V. +# Copy these into Vercel Dashboard → Project Settings → Environment Variables +# NEVER commit a file containing real credentials to git. + +# ── Database ──────────────────────────────────────────────────────────────── +DB_HOST=your-database-host.example.com +DB_PORT=3306 +DB_NAME=gcm +DB_USER=gcm_user +DB_PASS=change-me-to-a-strong-password + +# ── Notes ─────────────────────────────────────────────────────────────────── +# Root URL and timezone are hard-coded in vercel/build.php: +# g_root_path = https://www.ghanacouncil-nrw.de +# gTimezone = Europe/Berlin +# +# Recommended database providers (compatible with Vercel): +# PlanetScale https://planetscale.com (MySQL-compatible, free tier) +# Railway https://railway.app (MySQL/MariaDB, easy setup) +# Aiven https://aiven.io (MySQL, EU-hosted options) diff --git a/vercel/README.md b/vercel/README.md new file mode 100644 index 000000000..ee9a54716 --- /dev/null +++ b/vercel/README.md @@ -0,0 +1,33 @@ +# Vercel Deployment — Ghana Council e.V. + +This folder contains all Vercel-specific configuration and build scripts +for deploying the GCM application to [www.ghanacouncil-nrw.de](https://www.ghanacouncil-nrw.de). + +## Files + +| File | Purpose | +|------|---------| +| `build.php` | Build-time script that generates `adm_my_files/config.php` from Vercel environment variables | + +The root `vercel.json` controls deployment settings and references this folder. + +## Required Vercel Environment Variables + +Set these as **secrets** in your Vercel project dashboard (Settings → Environment Variables): + +| Variable | Description | +|----------|-------------| +| `DB_HOST` | Database server hostname | +| `DB_PORT` | Database port (optional) | +| `DB_NAME` | Database name | +| `DB_USER` | Database username | +| `DB_PASS` | Database password | + +## Deploy Steps + +1. Connect the `sandydiv3r/gcm` GitHub repository to a new Vercel project. +2. Add the environment variables above. +3. Deploy — Vercel will run `composer install` and `vercel/build.php` automatically. + +> The generated `adm_my_files/config.php` is not committed to git. +> It is produced fresh on every Vercel build from the secrets above. diff --git a/scripts/vercel-build.php b/vercel/build.php similarity index 97% rename from scripts/vercel-build.php rename to vercel/build.php index fb11dd6e8..71e5f92ee 100644 --- a/scripts/vercel-build.php +++ b/vercel/build.php @@ -46,7 +46,7 @@ \$gTimezone = 'Europe/Berlin'; PHP; -$configDir = __DIR__ . '/../adm_my_files'; +$configDir = __DIR__ . '/../../adm_my_files'; $configPath = $configDir . '/config.php'; if (!is_dir($configDir)) { From c1d88434d847b5e8f89055aa08d264f7790a80b8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 01:51:28 +0000 Subject: [PATCH 3/6] fix: use single front-controller function for Vercel free plan Vercel Hobby (free) plan caps deployments at 12 serverless functions. The previous "**/*.php" wildcard would create one function per PHP file (100+), immediately exceeding that limit. Changes: - vercel.json: replace wildcard functions with a single api/index.php function; set maxDuration: 10s (free plan max) - api/index.php: safe front controller that routes requests to the correct Admidio PHP file (root-level or modules/plugins/install/rss) with path-traversal protection; falls back to index.php for all other paths https://claude.ai/code/session_01XovpLEu54vubV3n1FyyGR2 --- api/index.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ vercel.json | 7 +++--- 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 api/index.php diff --git a/api/index.php b/api/index.php new file mode 100644 index 000000000..aa8688af5 --- /dev/null +++ b/api/index.php @@ -0,0 +1,59 @@ + Date: Tue, 24 Mar 2026 02:01:01 +0000 Subject: [PATCH 4/6] feat: embed demo credentials for zero-config Vercel deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace Vercel secret references (@db_host etc.) with plain demo values in vercel.json so the app deploys without any additional setup: DB_NAME = gcm_demo DB_USER = gcm_demo DB_PASS = GcmDemo@2024 DB_PORT = 3306 DB_HOST = REPLACE_WITH_DEMO_DB_HOST ← only value to fill in Anyone who pulls the repo and connects a Railway/PlanetScale MySQL database with these credentials gets a working demo instantly. Production deployments can override all values via Vercel env vars. https://claude.ai/code/session_01XovpLEu54vubV3n1FyyGR2 --- vercel.json | 10 +++++----- vercel/.env.example | 25 +++++++++---------------- vercel/build.php | 32 ++++++++++++-------------------- 3 files changed, 26 insertions(+), 41 deletions(-) diff --git a/vercel.json b/vercel.json index 90ea04007..48edb9656 100644 --- a/vercel.json +++ b/vercel.json @@ -18,10 +18,10 @@ } ], "env": { - "DB_HOST": "@db_host", - "DB_PORT": "@db_port", - "DB_NAME": "@db_name", - "DB_USER": "@db_user", - "DB_PASS": "@db_pass" + "DB_HOST": "REPLACE_WITH_DEMO_DB_HOST", + "DB_PORT": "3306", + "DB_NAME": "gcm_demo", + "DB_USER": "gcm_demo", + "DB_PASS": "GcmDemo@2024" } } diff --git a/vercel/.env.example b/vercel/.env.example index 881a6abcb..fb7e648aa 100644 --- a/vercel/.env.example +++ b/vercel/.env.example @@ -1,20 +1,13 @@ -# Vercel Environment Variables — Ghana Council e.V. -# Copy these into Vercel Dashboard → Project Settings → Environment Variables -# NEVER commit a file containing real credentials to git. +# Demo credentials — already set in vercel.json for zero-config deployment. +# To switch to production, override these in: +# Vercel Dashboard → Project Settings → Environment Variables -# ── Database ──────────────────────────────────────────────────────────────── -DB_HOST=your-database-host.example.com +DB_HOST=REPLACE_WITH_DEMO_DB_HOST # e.g. containers-us-west-123.railway.app DB_PORT=3306 -DB_NAME=gcm -DB_USER=gcm_user -DB_PASS=change-me-to-a-strong-password +DB_NAME=gcm_demo +DB_USER=gcm_demo +DB_PASS=GcmDemo@2024 -# ── Notes ─────────────────────────────────────────────────────────────────── # Root URL and timezone are hard-coded in vercel/build.php: -# g_root_path = https://www.ghanacouncil-nrw.de -# gTimezone = Europe/Berlin -# -# Recommended database providers (compatible with Vercel): -# PlanetScale https://planetscale.com (MySQL-compatible, free tier) -# Railway https://railway.app (MySQL/MariaDB, easy setup) -# Aiven https://aiven.io (MySQL, EU-hosted options) +# g_root_path = https://www.ghanacouncil-nrw.de +# gTimezone = Europe/Berlin diff --git a/vercel/build.php b/vercel/build.php index 71e5f92ee..729e3817e 100644 --- a/vercel/build.php +++ b/vercel/build.php @@ -2,32 +2,23 @@ /** * Vercel build script for Ghana Council e.V. * - * Generates adm_my_files/config.php from Vercel environment variables. - * Set the following secrets in your Vercel project: - * DB_HOST - Database server hostname - * DB_PORT - Database port (optional, leave blank for default) - * DB_NAME - Database name - * DB_USER - Database username - * DB_PASS - Database password + * Reads database credentials from environment variables defined in vercel.json. + * For the demo deployment all values are pre-filled. + * For production, override them in Vercel → Project Settings → Environment Variables. */ $dbHost = getenv('DB_HOST') ?: ''; $dbPort = getenv('DB_PORT'); -$dbName = getenv('DB_NAME') ?: ''; -$dbUser = getenv('DB_USER') ?: ''; -$dbPass = getenv('DB_PASS') ?: ''; +$dbName = getenv('DB_NAME') ?: 'gcm_demo'; +$dbUser = getenv('DB_USER') ?: 'gcm_demo'; +$dbPass = getenv('DB_PASS') ?: 'GcmDemo@2024'; $portValue = ($dbPort !== false && $dbPort !== '') ? (int)$dbPort : 'null'; -if (!$dbHost || !$dbName || !$dbUser) { - echo "WARNING: One or more required database environment variables (DB_HOST, DB_NAME, DB_USER) are not set.\n"; - echo " The application will not connect to the database without them.\n"; -} - $config = << Date: Tue, 24 Mar 2026 02:03:55 +0000 Subject: [PATCH 5/6] feat: switch database to Supabase (PostgreSQL) - vercel.json: update env to Supabase defaults (port 5432, db=postgres, user=postgres); host and password are placeholders to fill in once - vercel/build.php: change gDbType from mysql to pgsql - vercel/.env.example: document Supabase connection fields https://claude.ai/code/session_01XovpLEu54vubV3n1FyyGR2 --- vercel.json | 10 +++++----- vercel/.env.example | 15 +++++++-------- vercel/build.php | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/vercel.json b/vercel.json index 48edb9656..a7e3a5a65 100644 --- a/vercel.json +++ b/vercel.json @@ -18,10 +18,10 @@ } ], "env": { - "DB_HOST": "REPLACE_WITH_DEMO_DB_HOST", - "DB_PORT": "3306", - "DB_NAME": "gcm_demo", - "DB_USER": "gcm_demo", - "DB_PASS": "GcmDemo@2024" + "DB_HOST": "REPLACE_WITH_SUPABASE_HOST", + "DB_PORT": "5432", + "DB_NAME": "postgres", + "DB_USER": "postgres", + "DB_PASS": "REPLACE_WITH_SUPABASE_PASSWORD" } } diff --git a/vercel/.env.example b/vercel/.env.example index fb7e648aa..d76121c3a 100644 --- a/vercel/.env.example +++ b/vercel/.env.example @@ -1,12 +1,11 @@ -# Demo credentials — already set in vercel.json for zero-config deployment. -# To switch to production, override these in: -# Vercel Dashboard → Project Settings → Environment Variables +# Supabase (PostgreSQL) credentials +# Get these from: Supabase Dashboard → Project Settings → Database -DB_HOST=REPLACE_WITH_DEMO_DB_HOST # e.g. containers-us-west-123.railway.app -DB_PORT=3306 -DB_NAME=gcm_demo -DB_USER=gcm_demo -DB_PASS=GcmDemo@2024 +DB_HOST=db.xxxxxxxxxxxxxxxxxxxx.supabase.co +DB_PORT=5432 +DB_NAME=postgres +DB_USER=postgres +DB_PASS=your-supabase-db-password # Root URL and timezone are hard-coded in vercel/build.php: # g_root_path = https://www.ghanacouncil-nrw.de diff --git a/vercel/build.php b/vercel/build.php index 729e3817e..b07abf246 100644 --- a/vercel/build.php +++ b/vercel/build.php @@ -24,7 +24,7 @@ * Generated by Vercel build — do not edit manually. */ -\$gDbType = 'mysql'; +\$gDbType = 'pgsql'; \$g_tbl_praefix = 'adm'; \$g_adm_srv = '{$dbHost}'; From aa498bf15124322a790aea8e71ef9529f4116f7e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 02:19:48 +0000 Subject: [PATCH 6/6] Set Supabase DB_HOST for Ghana Council e.V. deployment https://claude.ai/code/session_01XovpLEu54vubV3n1FyyGR2 --- vercel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index a7e3a5a65..f421f9332 100644 --- a/vercel.json +++ b/vercel.json @@ -18,7 +18,7 @@ } ], "env": { - "DB_HOST": "REPLACE_WITH_SUPABASE_HOST", + "DB_HOST": "db.ubjlwpytufhcrnrjbfme.supabase.co", "DB_PORT": "5432", "DB_NAME": "postgres", "DB_USER": "postgres",