# CI / deploy scripts | File | Purpose | |------|---------| | `deploy-production.sh` | production deploy; the Jenkins job `erp-frontend-pipeline-production` holds a pasted copy and runs it ON the prod host (agent `Application-Node-Production`, workspace `/root/test/workspace/…`), building there with a 12 GB heap | | `deploy-instance.sh` | **any other instance** (demo clones, lead demos, blut24-style VMs): Jenkins job `erp-frontend-deploy-instance` (parameters `TARGET_HOST`, `BRANCH`) builds on the **Jenkins controller** (jenkins user, nvm Node 22.22.3, heap 10 GB, Debian 12 like the targets) and ships `.output` + native binaries over ssh/rsync; the target keeps its `.env` + `data/`, regenerates the `NUXT_*` overrides (`05-apply-env-overrides.sh`), restarts pm2 from the ecosystem file and rolls back when `/signin` does not answer. Targets need no build toolchain and no extra RAM (a 16 GB demo VM cannot build next to iDempiere) | | `jenkins-job-deploy-instance.xml` | the job definition (freestyle, built-in node, git `*/${BRANCH}` with credential `younex1`); the shell step is a pasted copy of `deploy-instance.sh` — paste again after changing the script. `__BUILD_TOKEN__` = remote-trigger token (set on the server, not in the repo) | ## Deploying to a demo / clone instance UI: Jenkins → `erp-frontend-deploy-instance` → *Build with Parameters* → `TARGET_HOST` (e.g. 192.168.12.68 = musterlager-demo), `BRANCH` (e.g. `dev`). ≈ 10 min (npm ci 1 min, build 7 min, sqlite3 source build 1 min, rsync + swap 1 min). Remote trigger (token on the server): `curl -X POST "https://jenkins.younex.de/job/erp-frontend-deploy-instance/buildWithParameters?token=…&TARGET_HOST=…&BRANCH=dev"`. The crumb is bound to the session: fetch `crumbIssuer/api/json` and POST with the SAME cookie jar (`curl -c jar -b jar …`), otherwise Jenkins answers 403. From the controller the token is in the job's `config.xml` (``), copied to `/root/.deploy-instance-token`. Prerequisites per target (true for every clone of the golden template): the jenkins user's key in `/root/.ssh/authorized_keys`, pm2 + nvm Node, `/root/template-cleanup/05-apply-env-overrides.sh`. New target → add it once to the jenkins user's `known_hosts` (`ssh-keyscan -H `), or rely on `StrictHostKeyChecking=accept-new` in the script. Re-creating the job on a fresh Jenkins: copy `jenkins-job-deploy-instance.xml` to `/var/lib/jenkins/jobs/erp-frontend-deploy-instance/config.xml` (replace `__BUILD_TOKEN__`), `chown -R jenkins:jenkins`, reload the configuration (or `systemctl restart jenkins` when nothing is building). Known state 2026-10-26: Jenkins queue holds `erp-frontend-pipeline` (dev) waiting for the offline agent "Laravel Middleware Integration".