From e8473c2554773caf100271ce5dd098ece61be7b0 Mon Sep 17 00:00:00 2001 From: Ryan Westfall Date: Thu, 6 Aug 2026 15:44:28 -0500 Subject: [PATCH] Register monica_site for django deploy (closes #14). Add app_catalog + host_apps (prod 8004 / beta 8014) on all webservers, document NPM/Postgres/worker singleton on adama, and list app in deploy.sh. --- IMPLEMENTATION.md | 10 ++++++++++ inventory/group_vars/all.yml | 10 ++++++++++ inventory/host_vars/adama.yml | 3 +++ inventory/host_vars/ai-server-4080.yml | 5 ++++- inventory/host_vars/roslin.yml | 3 +++ scripts/deploy.sh | 2 +- 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/IMPLEMENTATION.md b/IMPLEMENTATION.md index 4868b54..fc10ead 100644 --- a/IMPLEMENTATION.md +++ b/IMPLEMENTATION.md @@ -198,6 +198,7 @@ After Docker install, re-SSH so the `docker` group membership takes effect. | `scha` | django (docker) | adama + roslin + ai-server-4080 | prod | active/active behind NPM; beta port reserved | | `chat_web_app` | node-static (CRA) | adama + roslin + ai-server-4080 | beta + prod | active/active; built to `/var/www/.chat.aimloperations/html`, served by web-static nginx | | `chat_backend` | django (docker) | adama + roslin + ai-server-4080 | beta + prod | active/active behind NPM; Ollama `http://10.0.0.128:11434`; SearxNG `http://10.0.0.128:8088` (`SEARXNG_BASE_URL`) | +| `monica_site` | django (docker) | adama + roslin + ai-server-4080 | beta + prod | active/active behind NPM; no bundled Postgres (like `scha`); dj-queue **worker singleton on adama** only (`compose --profile worker`); Ollama social drafting via `10.0.0.128:11434` | Django apps use a **shared external Postgres** (via `DATABASE_URL` in each host's env file) so active/active replicas share one database. Beta and prod never share @@ -222,6 +223,7 @@ future beta replica. | dta_service | 8011 | 8001 | adama, roslin, ai-server-4080 | | scha | 8012 (*not deployed*) | 8002 | adama, roslin, ai-server-4080 | | chat_backend | 8013 | 8003 | adama, roslin, ai-server-4080 | +| monica_site | 8014 | 8004 | adama, roslin, ai-server-4080 | | dta_webapp (nginx) | 8081 | 8080 | adama, roslin, ai-server-4080 | | chat_web_app (nginx) | 8083 | 8082 | adama, roslin, ai-server-4080 | | SearxNG (LAN only) | — | **8088** | ai-server-4080 only (`searxng_stack`); not an NPM upstream | @@ -255,6 +257,10 @@ chat_backend secrets must use `SEARXNG_BASE_URL=http://10.0.0.128:8088`. - **django**: push per-app secret from control node `{{ secrets_dir }}//_.env` to host `{{ apps_env_dir }}` → git checkout at ref → copy `.env` into checkout → `docker compose build` → `up -d` → migrate (run once, shared DB). + **`monica_site` worker:** compose profile `worker` (dj-queue) is **not** started by + catalog deploy. After first/prod deploy, start once on **adama only**: + `docker compose -f docker-compose.prod.yml --profile worker up -d` + (do not run on roslin / ai-server-4080). - **node-static**: git checkout at ref → `npm ci` → `npm run build:` (writes to the app's `webroot_pattern`, e.g. `/var/www/{env}.realpath.app/html` or `/var/www/{env}.chat.aimloperations/html`). @@ -281,6 +287,7 @@ point each domain at the backend(s): | scha | `schawheaton.aimloperations.com`, `schawheaton.com` (+ www) | `adama:8002` + `roslin:8002` (+ `ai-server-4080:8002`) | | chat_web_app | `chat.aimloperations.com` (+ www); `beta.chat.aimloperations.com` | `adama:8082` / `8083` + same on roslin / ai-server-4080 | | chat_backend | `chatbackend.aimloperations.com`; `beta.chatbackend.aimloperations.com` | `adama:8003` / `8013` + same on roslin / ai-server-4080 | +| monica_site | `mkdrealtor.com` (+ www); `monica-preview.aimloperations.com` (beta) | `adama:8004` / `8014` + same on roslin / ai-server-4080 | ### Required changes IN each app repo (owned separately) @@ -313,6 +320,8 @@ do not). | scha | beta | `scha_beta` | `postgres://westfarn:@10.0.0.230:5432/scha_beta` | | chat_backend | prod | `chat_backend` | `postgres://westfarn:@10.0.0.230:5432/chat_backend` | | chat_backend | beta | `chat_backend_beta` | `postgres://westfarn:@10.0.0.230:5432/chat_backend_beta` | +| monica_site | prod | `monica_site` | `postgres://westfarn:@10.0.0.230:5432/monica_site` | +| monica_site | beta | `monica_site_beta` | `postgres://westfarn:@10.0.0.230:5432/monica_site_beta` | Server prereqs on 10.0.0.230: create each DB + grant `westfarn`; `listen_addresses` covers LAN; `pg_hba.conf` allows `10.0.0.0/24`; firewall opens @@ -390,6 +399,7 @@ Store vault password for CI in a file readable only by the Act runner (e.g. `~/. | 10a | Register + deploy `scha` (all webservers, port 8002) | In progress ([scha#19](https://git.aimloperations.com/ai_ml_operations/scha/issues/19)) | | 10b | Register + deploy `chat_web_app` (node-static, ports 8082/8083) | Done (prod); beta ([#7](https://git.aimloperations.com/ai_ml_operations/server-infra/issues/7), [chat_web_app#35](https://git.aimloperations.com/ai_ml_operations/chat_web_app/issues/35)) | | 10c | Register + deploy `chat_backend` (django, ports 8003/8013) | Done (prod); beta ([#7](https://git.aimloperations.com/ai_ml_operations/server-infra/issues/7), [chat_backend#26](https://git.aimloperations.com/ai_ml_operations/chat_backend/issues/26)) | +| 10d | Register + deploy `monica_site` (django, ports 8004/8014; worker on adama) | In progress ([#14](https://git.aimloperations.com/ai_ml_operations/server-infra/issues/14)) | | 11 | Gitea container registry (optional) | Future | ## Open Decisions diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 0b459c0..29398ff 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -103,6 +103,16 @@ app_catalog: compose_file: docker-compose.prod.yml web_service: web migrate_cmd: "uv run python manage.py migrate --noinput" + monica_site: + type: django + repo: "{{ git_base_url }}/ai_ml_operations/monica_site.git" + default_branch: main + compose_file: docker-compose.prod.yml + web_service: web + migrate_cmd: "uv run python manage.py migrate --noinput" + # dj-queue worker (compose profile `worker`) is a singleton — start only on + # adama after deploy: docker compose -f docker-compose.prod.yml --profile worker up -d + # Catalog deploys web + migrate only; worker is manual / ops step. # Deploy filter vars. CI passes these; manual runs may leave them undefined # to (re)deploy every app listed in the host's host_apps. diff --git a/inventory/host_vars/adama.yml b/inventory/host_vars/adama.yml index 9cd582c..4cfa248 100644 --- a/inventory/host_vars/adama.yml +++ b/inventory/host_vars/adama.yml @@ -16,3 +16,6 @@ host_apps: - { name: chat_web_app, env: beta, port: 8083 } - { name: chat_backend, env: prod, port: 8003 } - { name: chat_backend, env: beta, port: 8013 } + - { name: monica_site, env: prod, port: 8004 } + - { name: monica_site, env: beta, port: 8014 } + # monica_site dj-queue worker (compose --profile worker) runs ONLY on adama. diff --git a/inventory/host_vars/ai-server-4080.yml b/inventory/host_vars/ai-server-4080.yml index 8be4019..1616ef3 100644 --- a/inventory/host_vars/ai-server-4080.yml +++ b/inventory/host_vars/ai-server-4080.yml @@ -33,4 +33,7 @@ host_apps: - { name: chat_web_app, env: prod, port: 8082 } - { name: chat_web_app, env: beta, port: 8083 } - { name: chat_backend, env: prod, port: 8003 } - - { name: chat_backend, env: beta, port: 8013 } \ No newline at end of file + - { name: chat_backend, env: beta, port: 8013 } + - { name: monica_site, env: prod, port: 8004 } + - { name: monica_site, env: beta, port: 8014 } + # monica_site worker is NOT on ai-server-4080 — singleton on adama only. \ No newline at end of file diff --git a/inventory/host_vars/roslin.yml b/inventory/host_vars/roslin.yml index 315c291..f83f2f2 100644 --- a/inventory/host_vars/roslin.yml +++ b/inventory/host_vars/roslin.yml @@ -13,3 +13,6 @@ host_apps: - { name: chat_web_app, env: beta, port: 8083 } - { name: chat_backend, env: prod, port: 8003 } - { name: chat_backend, env: beta, port: 8013 } + - { name: monica_site, env: prod, port: 8004 } + - { name: monica_site, env: beta, port: 8014 } + # monica_site worker is NOT on roslin — singleton on adama only. diff --git a/scripts/deploy.sh b/scripts/deploy.sh index b881ba1..60c2947 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -17,7 +17,7 @@ Deploy applications with deploy-apps.yml. HOST Optional. Limit to one host: adama, roslin, or ai-server-4080. Options: - --app NAME App to deploy (company_site, dta_service, dta_webapp, scha, chat_web_app, chat_backend) + --app NAME App to deploy (company_site, dta_service, dta_webapp, scha, chat_web_app, chat_backend, monica_site) --env ENV Environment: beta or prod --ref REF Git ref/sha to deploy (default: master) --check Dry run