INSTANCE_FLEET_AUTOMATION.md (2039B)
1 # Instance Fleet Automation (Detect, Create, Update, Restart) 2 3 Use this when you run several Bzl repos on one server and want one workflow for all of them. 4 5 ## 1) Detect Bzl instances 6 7 ```bash 8 cd /root/Bzl 9 npm run instances:scan -- --roots=/root,/srv,/opt,/home --max-depth=7 10 ``` 11 12 Detection sources: 13 - Filesystem scan for compose projects and Bzl source markers 14 - Docker labels (`com.docker.compose.project.working_dir`) so compose-only folders can still be found 15 16 Supported compose filenames: 17 - `compose.yaml` 18 - `compose.yml` 19 - `docker-compose.yml` 20 - `docker-compose.yaml` 21 22 ## 2) Create a new instance folder 23 24 ```bash 25 cd /root/Bzl 26 npm run instance:create -- --path=/opt/bzl-new --port=3405 --registration-code='replace-me' --hostname=new.example.com 27 ``` 28 29 What this does: 30 - Clones `https://github.com/bzlapp/Bzl.git` (`main`) into `--path` 31 - Writes `.env` with `PORT`, `HOST`, and `REGISTRATION_CODE` 32 - Starts Docker Compose unless `--no-start` is used 33 34 Important: 35 - `--path` must be empty 36 - `--port` must be unique per instance 37 38 Useful flags: 39 - `--repo=...` 40 - `--branch=...` 41 - `--no-start` 42 - `--dry-run` 43 44 ## 3) Update all instances to latest `main` 45 46 ```bash 47 cd /root/Bzl 48 npm run instances:update -- --roots=/root,/srv,/opt,/home --max-depth=7 --dry-run 49 npm run instances:update -- --roots=/root,/srv,/opt,/home --max-depth=7 50 ``` 51 52 Useful flags: 53 - `--skip-git` (restart/recreate only) 54 - `--skip-build` (skip image build) 55 - `--branch=main` 56 - `--remote=origin` 57 - `--dry-run` 58 59 ## 4) Restart all instances (fast path) 60 61 ```bash 62 cd /root/Bzl 63 npm run instances:update -- --roots=/root,/srv,/opt,/home --max-depth=7 --skip-git --skip-build 64 ``` 65 66 ## 5) Verify each instance 67 68 ```bash 69 docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Ports}}\t{{.Status}}' 70 curl -fsS http://127.0.0.1:<port>/api/health 71 ``` 72 73 ## DNS + reverse proxy reminder 74 75 For each hostname: 76 1. DNS `A` record points to the server IP 77 2. Caddy routes hostname to the instance port 78 3. Public HTTPS URL returns app + `/api/health` 79 80 See also: `docs/DIGITALOCEAN_DEPLOYMENT_AND_COST.md`