bzl

self-hosted ephemeral community engine
Log | Files | Refs | README | LICENSE

MULTI_INSTANCE_DOCKER.md (1915B)


      1 # Multi-Instance Docker Stack (Single Compose Project)
      2 
      3 This workflow runs many Bzl instances from one generated compose file (`multi_instance/docker-compose.yml`).
      4 
      5 Use this when you want:
      6 - one config file for all instances
      7 - one command to start all instances
      8 - one command to update all instances
      9 
     10 ## 1) Create or edit the config
     11 
     12 ```bash
     13 cd /root/Bzl
     14 npm run multi:init
     15 ```
     16 
     17 If `multi_instance/instances.json` does not exist, a template is created.
     18 
     19 Key fields:
     20 - `instances[].id`: stable ID for env/service naming
     21 - `instances[].hostname`: public hostname
     22 - `instances[].hostPort`: unique local port
     23 - `instances[].registrationCode`: per-instance registration code
     24 
     25 ## 2) Generate compose + env outputs
     26 
     27 ```bash
     28 cd /root/Bzl
     29 npm run multi:init
     30 ```
     31 
     32 Generated:
     33 - `multi_instance/docker-compose.yml`
     34 - `multi_instance/env/<id>.env`
     35 - `multi_instance/DNS_CHECKLIST.md`
     36 
     37 Optional (Cloudflare tunnel DNS automation):
     38 
     39 ```bash
     40 npm run multi:init -- --route-dns
     41 ```
     42 
     43 ## 3) Start all configured instances
     44 
     45 ```bash
     46 docker compose -f multi_instance/docker-compose.yml up -d --build --remove-orphans
     47 ```
     48 
     49 ## 4) Update all configured instances
     50 
     51 ```bash
     52 cd /root/Bzl
     53 npm run multi:update
     54 ```
     55 
     56 Default behavior:
     57 1. `git fetch origin`
     58 2. `git checkout main`
     59 3. `git pull --ff-only origin main`
     60 4. regenerate compose/env outputs
     61 5. `docker compose -f multi_instance/docker-compose.yml up -d --build --remove-orphans`
     62 
     63 Useful flags:
     64 - `--skip-git`
     65 - `--skip-build`
     66 - `--route-dns`
     67 - `--dry-run`
     68 - `--config=/path/to/instances.json`
     69 
     70 ## 5) Validate routing
     71 
     72 ```bash
     73 curl -fsS http://127.0.0.1:<hostPort>/api/health
     74 ```
     75 
     76 Then verify each public hostname resolves to the expected instance.
     77 
     78 ## When to use this vs fleet automation
     79 
     80 - Use this doc (`multi:*`) if you intentionally keep all instances in one managed stack.
     81 - Use `docs/INSTANCE_FLEET_AUTOMATION.md` if your instances are spread across independent folders/projects.