chore(tm): file #17 — production deployment plan
Comprehensive Coolify-prod runbook covering: pgvector PG provisioning, MinIO bucket, shira-hermes dockerimage app, Infisical /prod secrets, data migration choice (pg_dump+S3 mirror vs fresh ingest), KB extension install on prod EspoCRM, SmartAssistant integration config, optional n8n auto-scan workflow clone, DNS, and end-to-end smoke test sequence. Currently the entire stack is dev-only — this task makes KB live on the production CRM at crm.prod.marcus-law.co.il.
This commit is contained in:
@@ -182,6 +182,18 @@
|
||||
"dependencies": [12],
|
||||
"createdAt": "2026-04-25T13:30:00Z"
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"title": "Deploy KnowledgeBase + shira-hermes to production (Hetzner)",
|
||||
"description": "Right now the entire KB stack runs only on the dev server (192.168.10.206 / dev.marcus-law.co.il): shira-hermes, the insurance_kb Postgres database with pgvector, the MinIO bucket insurance-kb, and the KnowledgeBase EspoCRM extension installed on espocrm.dev. Production CRM (https://crm.prod.marcus-law.co.il, Hetzner 46.62.204.107) has none of it. Need to bring up an equivalent stack on prod so the live CRM can use the KB. Infrastructure pieces should be sized for production, not just copies of dev.",
|
||||
"status": "pending",
|
||||
"priority": "high",
|
||||
"details": "Pieces to provision on Hetzner Coolify (project espoCRM/Useful MicroServices on prod, NOT dev):\n\n1. PostgreSQL with pgvector — image pgvector/pgvector:pg16 (matching dev). Either dedicated DB service for shira-hermes or extend a shared one. Create role shira_kb + DB insurance_kb + extension pgvector. Migrations: same DDL we ran on dev (kb_source, kb_chunk with vector(1024) embedding, hnsw + gin indexes). After multi-topic Phase 1 (#12) ships, also create kb_topic + kb_source.topic_id.\n\n2. MinIO — separate Coolify service, e.g. minio-prod. Bucket insurance-kb with the same inbox/{law,regulation,circular} + processed/{...} + failed/{...} layout. Or use Hetzner Object Storage as an S3-compatible alternative; KB code already uses any S3 endpoint.\n\n3. shira-hermes app — Coolify dockerimage app pulling gitea.dev.marcus-law.co.il/espocrm-extensions/shira-hermes:latest. Needs network access to: prod PG, prod MinIO, https://ai-gateway.prod.marcus-law.co.il (NOT the dev gateway), and the prod EspoCRM API. Domain: shira.prod.marcus-law.co.il. Health check at /api/health. Same env vars as dev shira (PORT, API_KEY, AI_GATEWAY_URL, AI_GATEWAY_API_KEY, CLAUDE_MODEL, ESPOCRM_URL, ESPOCRM_API_KEY, KB_DATABASE_URL, VOYAGE_API_KEY, VOYAGE_MODEL, KB_S3_*) but pointing at prod resources.\n\n4. Secrets in Infisical, environment 'prod':\n - /espocrm: KB_DATABASE_URL, ADMIN_USER, API_KEY, API_USER (mirroring dev keys but for prod)\n - /ai-gateway: API_KEY, ESPOCRM_URL=https://crm.prod.marcus-law.co.il, ESPOCRM_API_KEY (already exists for the prod gateway)\n - /external-apis/voyage: VOYAGE_API_KEY (decision: separate prod key for billing isolation, or share with dev — user's choice)\n - /minio (new folder): MINIO_ROOT_USER, MINIO_ROOT_PASSWORD, S3_ENDPOINT, CONSOLE_URL\n - /mattermost: WEBHOOK_KB_INGEST (or skip notifications on prod)\n - shira-hermes app pulls them via Coolify env_vars referencing Infisical (the n8n workflow Infisical→Coolify Sync (id U3FiSwdvjHtWK2rh) syncs them automatically once configured).\n\n5. Data: choose between (A) hot-migrate from dev — pg_dump --table=kb_source --table=kb_chunk + pg_restore on prod, then mc mirror s3://dev/insurance-kb to s3://prod/insurance-kb. Preserves the 1024-dim embeddings already computed (no Voyage cost). Or (B) fresh on prod — re-ingest the 5 PDFs via the inbox/scan-inbox flow + re-scrape the law from Wikisource. Voyage cost ~$2-3 in embeddings. Cleaner state but slower (~30-60 min). User should pick based on whether dev's data is considered authoritative or needs review.\n\n6. EspoCRM prod (crm.prod.marcus-law.co.il, image gitea.prod.marcus-law.co.il/chaim/legalcrm-espocrm:9.3.3):\n - Install KnowledgeBase extension: scp KnowledgeBase-X.Y.Z.zip → docker cp into the prod espocrm container → php /var/www/html/command.php extension --file=...\n - Configure SmartAssistant Integration via Admin UI: webhookUrl=https://shira.prod.marcus-law.co.il/, apiKey=<shared with shira>. The KB extension reads these from the SmartAssistant integration data field (KnowledgeBaseService::getBaseUrl + getApiKey).\n - Verify EspoCRM scope/role config so non-portal users get KB access (current dev rule).\n\n7. n8n prod (https://n8n.prod.marcus-law.co.il): clone the dev workflow 'EspoCRM | KB Auto-Scan' (id M2gyevYjiLkfDGav). Adjust the URL from https://shira.dev.marcus-law.co.il to https://shira.prod.marcus-law.co.il + use the prod admin key. Cron: every 15 min, same as dev. Optional — only needed if firms upload via the manual MinIO inbox flow (Phase 2/#13 will replace this with self-service UI uploads).\n\n8. DNS: add shira.prod.marcus-law.co.il pointing at the prod traefik (same as crm.prod.marcus-law.co.il). Coolify will provision the cert.\n\n9. Smoke test in this order: GET https://shira.prod.marcus-law.co.il/api/health 200; admin scan-inbox returns 0 items if data was migrated (else processes pending uploads); /kb/sources returns the 6 (or however many were migrated); /kb/search 'תקנה 36' returns hits; install KB ext on espocrm prod, open the בסיס ידע tab, run search + ask end-to-end; verify ask streams via SSE through the prod entry point.",
|
||||
"testStrategy": "1) Each Coolify service status=running:healthy after deploy. 2) Health check curl https://shira.prod.marcus-law.co.il/api/health returns {status:'ok'} or equivalent. 3) From inside the espocrm prod container: curl with X-Api-Key against /kb/sources returns the migrated/seeded sources. 4) In the prod CRM browser: open בסיס ידע, search returns hits, ask streams progress and lands an answer. 5) PDF iframe (?entryPoint=KnowledgeBasePdf&sourceId=N) loads. 6) After 24h: confirm Voyage usage dashboard shows queries from the prod IP (rule out missing API key). 7) Backup baseline: pg_dump of insurance_kb on prod scheduled (Coolify's database_backups feature for the new PG).",
|
||||
"subtasks": [],
|
||||
"dependencies": [],
|
||||
"createdAt": "2026-04-25T14:00:00Z"
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"title": "Phase 5 (optional) — Per-topic ACL by EspoCRM role",
|
||||
|
||||
Reference in New Issue
Block a user