Commit Graph
20 Commits
Author SHA1 Message Date
Artur Moreira f5b9a5d058 docs(monitoring): BIT-746 public URL probe, inventory, alert runbook
Extend healthcheck.sh with optional BRIDGE_DEEP_URL and PUBLIC_PAGE_URL
(customer-facing HTTPS with redirects). Document must-not-fail checks,
intervals, and escalation in docs/monitoring.md and a dedicated runbook.

Paperclip-Issue: BIT-746
Paperclip-Run: 04281f51-59ac-4267-a269-f12269dc2320
Paperclip-Agent: Tiago Neves (urlKey tiago-neves; id 5d084b36-f38f-42a5-a92a-520005afda4f)
Made-with: Cursor
2026-04-03 00:23:28 +00:00
Artur Moreira f15287e589 feat(monitoring): add service health monitoring with alerts (BIT-744)
Automated health monitoring for the news-platform services on CT222,
motivated by the bridge crash-loop incident (BIT-743) where 3,608
restarts went undetected until manual discovery.

Health endpoints:
- Bridge /health enhanced with optional ?checks=true for deep
  dependency probes (WordPress, Redis) and uptime reporting
- Frontend /health.json added as Astro API route

Monitoring infrastructure:
- healthcheck.sh: periodic probe script with HTTP checks, systemd
  restart-count detection, cooldown logic, and Ntfy push alerting
- news-healthcheck.timer: runs every 3 min (detection < 5 min)
- [email protected]: OnFailure template for instant crash alerts
- All three service units updated with OnFailure= directive
- deploy.sh updated to install monitoring units and env file

Paperclip-Agent: peter-spark
Paperclip-Issue: BIT-744
Paperclip-Run: 405ab587-8b8b-4963-8867-0feb95a994e3
2026-04-02 23:37:06 +00:00
Artur Moreira cccf26f657 fix(bridge): prevent WriterConfigService from crashing on EACCES
The module-level singleton called mkdirSync('config/writers') which
fatally crashed the bridge when running as www-data without write
permission to the working directory. The bridge has been crash-looping
with restart counter >3600, taking andebol.net offline.

Constructor now catches EACCES gracefully (warn + degrade) instead of
killing the process. Deploy scripts also ensure the directory exists
with correct ownership.

Paperclip-Agent: peter-spark
Paperclip-Issue: BIT-743
Paperclip-Run: 817ec0b4-3778-44ae-8c07-efd97a2bdd86
2026-04-02 23:28:50 +00:00
Artur MoreiraandPaperclip a77c293d0e feat(wordpress): nginx + PHP-FPM stacks; retire Apache images (BIT-578)
- Use wordpress:6-php8.3-fpm with nginx:alpine sidecars; keep host ports 8080/8081
- Add shared wp_html / wp_andebol_html volumes so nginx can serve the same docroot as FPM
- Nginx: try_files permalinks, proxy headers, HTTP_AUTHORIZATION for App Passwords
- Update deploy scripts to force-recreate nginx with wordpress when public URL is fixed
- Refresh README and deployment docs

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-28 01:15:51 +00:00
Artur Moreira 50c5fafcd9 chore(deploy): extend andebol smoke for search/archive; fix Host header env (BIT-591)
- Assert GET /search, /search?q=te, /category/all return 200
- Use SMOKE_HOST instead of HOST for the vhost header (HOST=0.0.0.0 in agent envs caused 403)

Made-with: Cursor
2026-03-27 16:57:43 +00:00
Artur MoreiraandPaperclip f599f54709 fix(nginx): expose /wp-content/uploads/ publicly for article featured images
WordPress article images (featured_media) are served from /wp-content/uploads/.
The existing /wp-content/ block restricts access to RFC1918 IPs, blocking public
browsers from loading article images. Add a longer ^~ prefix match for the uploads
subdirectory so it wins over the restricted block, with 7d cache headers.

Paired with setting ANDEBOL_WORDPRESS_PUBLIC_URL=https://andebol.net in .env so
WordPress returns public image URLs instead of localhost:8081.

Co-Authored-By: Paperclip <[email protected]>
2026-03-27 11:25:27 +00:00
Artur MoreiraandPaperclip aff73455d0 feat(andebol): public WP login surface, auth nav, /entrar and /registar
- Nginx: proxy wp-login.php, wp-includes, wp-admin css/js/images, and
  wp-content/languages without RFC1918 allow (works with real_ip); keep
  rest of wp-admin, wp-content, wp-json restricted.
- Domain config: auth_links on andebol.net; optional DomainConfig field.
- Astro: Portuguese/English auth labels, header/footer links, redirects.
- Bridge: omit internal detail from 503 JSON (avoid leaking upstream msgs).
- Docs: deployment + domains schema for auth and membership.

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-27 10:57:57 +00:00
738f847d36 feat: theme system + institutional theme + andebol.net domain config
Add domain-aware theme system (BIT-494, BIT-495, BIT-496, BIT-497):

- Theme architecture: move shared components into src/themes/sports/,
  create src/themes/institutional/ with handball-oriented design
- Domain config: andebol.net.json (institutional theme, pt-PT locale,
  handball categories, WP endpoint port 8081)
- theme.ts library: resolves theme components per domain config
- Updated layouts/pages to use theme-aware component loading
- Updated docs: domains.md, frontend.md with theme system docs
- Smoke test script for andebol.net
- WordPress .env.example with andebol env vars

Note: this work was completed in BIT-494/495/496/497 but was
never committed — committing now to unblock andebol.net deploy.

Co-Authored-By: Paperclip <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-03-27 08:38:41 +00:00
Artur Moreira e15e88ef6c fix(nginx): default_server for all NPM hostnames + WP port map
Use default_server and server_name _ so domains like andebol.net reach Astro
instead of the Debian nginx welcome page. Install map Host→WordPress port
(8080 default, andebol.net→8081). deploy.sh and webhook-deploy install
conf.d snippet and remove sites-enabled/default.

docs/deployment.md: document multi-domain NPM workflow.

Refs: BIT-345
2026-03-25 12:34:18 +00:00
Artur Moreira 67f655820a fix(wordpress): broaden proxy detection for WP_HOME inference (BIT-470)
- Treat X-Forwarded-Proto or X-Real-IP as sufficient proxy hints alongside X-Forwarded-For
- Normalize WORDPRESS_PUBLIC_URL in ensure-public-url script (trailing slash, any localhost:8080 substring)
- Update deployment.md and wordpress README

Made-with: Cursor
2026-03-24 19:47:35 +00:00
Artur Moreira 5e14e2df47 fix(deploy): auto-set WordPress public URL and sync wp_options on LXC
Add wordpress-ensure-public-url.sh (exit 2 when .env updated) and
wordpress-sync-options-url.sh to align siteurl/home with HTTPS. Wire
into deploy.sh and webhook-deploy.sh for /opt/news-platform only so
the board does not need manual .env or SQL for BIT-470/BIT-471.

Made-with: Cursor
2026-03-24 19:02:10 +00:00
Artur Moreira eee991400e fix(wordpress): wp-admin redirect behind NPM (BIT-470)
Preserve X-Forwarded-Proto from the edge proxy in CT nginx so WordPress
sees HTTPS. When WORDPRESS_PUBLIC_URL still defaults to localhost:8080,
derive WP_HOME/WP_SITEURL from Host and forwarded headers for proxied
requests (X-Forwarded-For present). Document behaviour in deployment and
wordpress README.

Made-with: Cursor
2026-03-24 18:53:25 +00:00
Artur Moreira 7095765669 feat(deploy): LXC bootstrap, smoke script, /health in nginx, deployment doc (BIT-426)
- Add deploy/lxc/setup.sh for Ubuntu 24 CT (nginx, redis, docker, node 22, pm2)
- Add deploy/scripts/smoke-newsproject.sh for /, /health, wp-json checks
- Proxy GET /health to Fastify in newsproject.bitreport.pt nginx config
- Update docs/deployment.md: remove stub, NPM hostname, bootstrap order, canonical nginx path

Made-with: Cursor
2026-03-24 02:03:40 +00:00
Artur MoreiraandPaperclip 642dec80dc docs(nginx): clarify wp-admin reachability behind NPM
Align README and deployment.md with reality: allow/deny use $remote_addr
on the CT, so a private-IP reverse proxy makes /wp-admin/ reachable from
the public Internet. Add nginx header comments and optional real_ip notes.

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-23 23:13:35 +00:00
Artur MoreiraandPaperclip 7e61271bc5 feat(nginx): proxy wp-admin e wp-json com allow redes privadas
Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-23 20:07:55 +00:00
Artur MoreiraandPaperclip a8b71762d9 fix(news-platform): SSR domain routing, resilient homepage, Gitea deploy hook
- Forward X-Site-Host from Astro to the bridge so loopback calls use the public domain JSON
- Normalize newsproject.bitreport.pt.json (categories slug/label, wp on 127.0.0.1:8080)
- Degrade homepage/trending when WordPress is down instead of 500
- Extend webhook-deploy.sh for config/ and wordpress/ changes; add deploy-hook-server + systemd unit
- Document automatic Gitea webhook flow in docs/deployment.md; align DOMAINS_CONFIG_PATH env

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-23 19:47:19 +00:00
Artur MoreiraandPaperclip 4948fc5c72 fix(deploy): add NODE_ENV=production to bridge.env.example
Without this, pino-pretty (devDep) was required at runtime causing
the bridge service to crash on first boot.

Co-Authored-By: Paperclip <[email protected]>
2026-03-23 19:39:03 +00:00
Artur MoreiraandPaperclip 0e27dd8359 fix(deploy): use full npm ci in webhook-deploy to include devDeps for tsc build
npm ci --omit=dev excluded TypeScript (devDep) causing the build step to fail.
Build needs devDeps; runtime doesn't because it runs compiled dist/.

Co-Authored-By: Paperclip <[email protected]>
2026-03-23 19:38:30 +00:00
Artur MoreiraandPaperclip 0e3a1afb3b feat: deploy pipeline — systemd units, Nginx, deploy scripts (BIT-352)
deploy/systemd/:
  - news-frontend.service (Astro SSR :4321)
  - news-bridge.service (Fastify :3200)
  - news-wordpress.service (Docker Compose wrapper)
  - frontend.env.example + bridge.env.example

deploy/nginx/:
  - newsproject.bitreport.pt.conf (reverse proxy → :4321, /api/ → :3200)
  - Nginx config validated OK on CT 222

deploy/scripts/:
  - deploy.sh — full from-scratch deploy (clone, build, install, start)
  - webhook-deploy.sh — incremental deploy on git push (cron-friendly)

Tested on CT 222 (10.10.50.140):
  - nginx -t → OK
  - systemd units installed (news-frontend/bridge/wordpress)
  - news-wordpress enabled; frontend/bridge pending Astro build

Remaining manual steps:
  - DHCP reservation for 10.10.50.140
  - NPM proxy host: newsproject.bitreport.pt → http://10.10.50.140
  - Run deploy.sh after bridge.env and frontend.env are configured

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-23 15:48:43 +00:00
Tiago NevesandPaperclip f7274c9c4e chore: scaffold initial project structure
Creates the base directory layout for the news-platform:
frontend/, bridge/, wordpress/, config/domains/, docs/, deploy/.

Ref: BIT-346 — Create Gitea repo + scaffold project structure

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-23 14:06:29 +00:00