The docs lived on one lineage and the fleet code on another. That is why six pages described a shared fleet key as how an agent authenticates, why COLLECTOR-AUTH had to warn that the per-PC credential code was not in the repository it sat in, and why ADR-019 recorded a decision whose implementation was somewhere else. Documentation that cannot see the code it documents goes stale by construction, and no amount of editing fixes that. So the corpus moves here: 84 files, 56 pages, 20 ADRs, the proposals, INDEX.md, llms.txt and both gates. Filenames are unchanged, because a wiki page name is derived from the filename and a rename breaks every link anybody saved. THE POINT OF THE MOVE IS THE CORRECTION IT ENABLES. Every caveat that said "not in this tree" was false the moment the files landed beside the code, so each was rewritten from what is actually here: - COLLECTOR-AUTH gained the real enroll request body, the two bounds on the unauthenticated route (per-IP rate limit, pending cap with stale rows dropped before a real PC is refused), and the rejected pending reason that binds to the endpoint identity rather than the nonce. - ADR-019 now describes an implementation that is present, including its tests, and says plainly that what remains is the FLEET migration, not the code. - proposals/device-identity claimed phase 1 was unbuilt. plugins/computers declares deviceid on the collector schema and prefers it over the older fallbacks. Corrected in the page, its summary and the index. WINDOWS/IIS IS NOW DOCUMENTED AS THE LEGACY PATH, per the product decision, and carefully: it is what production runs today. Every Windows page opens by saying it is supported, not for a new site, and where a new site should go instead. No procedure was cut - an operator on an IIS box at 2am needs these pages to work exactly as well tomorrow. MIGRATE-TOPOLOGY stops being a footnote and becomes the off-ramp, which is why it nearly doubled: what was there did not match how the Docker stack really works here. The Docker material that already lived on this line was kept and given ownership rather than buried under the ported Windows-centric prose: DEPLOY now describes the four services, the migrate service that runs the upgrade chain before api starts, TLS terminated by nginx, and the plugin count corrected from thirteen to seventeen - a number both lineages had wrong. ROADMAP is rewritten from evidence rather than memory: what has shipped, read out of the changelog, the ADRs and the manifests, and ahead of it exactly two items - finalize a distributed release and polish the setup wizard. PROJECT-MAP is generated and was stale; the GENERATOR was what was wrong. --check passes now. API-REFERENCE is retired to a pointer. /api/docs serves 573 operations with derived auth, query parameters and harvested examples, and a hand-written page competing with that is a liability. The file stays so its wiki page and its inbound links survive. AND THE MOVE TURNED ON A SCRUB THAT HAD NEVER RUN HERE. test_docs_publishable keys on docs/*.md, which this line did not have, so it skipped - its own comment predicted what would surface. Porting the corpus activated it and it found 48 lines that must not reach a published wiki: branch names abbreviating the site, assistant-tooling paths, the site name in two deployment pages, and an employee ID in a Windows path that the scrub does not even look for.
137 lines
5.0 KiB
Markdown
137 lines
5.0 KiB
Markdown
<!-- docmeta
|
|
purpose: howto
|
|
audience: adopter, developer
|
|
status: current
|
|
summary: Put the Docker stack on a throwaway Windows VM to try it or rehearse a deploy, and what the helper script gets wrong.
|
|
loadwith: none
|
|
-->
|
|
# Deploying the stack to a Windows VM
|
|
|
|
> **Where this sits:** a rehearsal, not a site. For a real site follow
|
|
> [DEPLOY](../DEPLOY.md). To only LOOK at a build with no source at all,
|
|
> [DEV-BUILD-TEST](../DEV-BUILD-TEST.md) pulls a published image and is one
|
|
> script.
|
|
|
|
A Windows VM with Docker Desktop is the cheapest way to prove a deploy before
|
|
doing it for real: the stack is identical to a site's, the VM can be reverted,
|
|
and nothing on it matters. This page is the VM-specific part - getting the code
|
|
there, the firewall, reaching it from the host. Everything else is
|
|
[DEPLOY](../DEPLOY.md).
|
|
|
|
## On the VM
|
|
|
|
1. **Docker Desktop**, installed and running.
|
|
2. **Git Bash or WSL**, for the bash commands.
|
|
3. Enough RAM given to Docker. The stack is MySQL plus a Python container plus
|
|
nginx; 8GB to Docker is comfortable.
|
|
|
|
## Step 1: Get the code onto the VM
|
|
|
|
```powershell
|
|
# From a network share
|
|
Copy-Item -Recurse \\<host>\shopdb-flask C:\shopdb
|
|
|
|
# Or clone it
|
|
git clone <your-remote>/shopdb-flask.git C:\shopdb
|
|
|
|
# Or hand it over as a zip, which is what an isolated VM usually wants
|
|
Expand-Archive -Path C:\shopdb-deploy.zip -DestinationPath C:\shopdb
|
|
```
|
|
|
|
## Step 2: Bring it up
|
|
|
|
The pre-built path is the one to use on a VM: npm inside the image is slow and
|
|
is the step most likely to fail behind a proxy. Build the frontend once on the
|
|
host or on the VM, then build the image from it -
|
|
[DOCKER-PREBUILT-APPROACH](DOCKER-PREBUILT-APPROACH.md).
|
|
|
|
```powershell
|
|
cd C:\shopdb
|
|
copy .env.example .env
|
|
# Edit .env: SECRET_KEY, JWT_SECRET_KEY, MYSQL_ROOT_PASSWORD, MYSQL_PASSWORD,
|
|
# CORS_ORIGINS. Generate a secret with:
|
|
# python -c "import secrets; print(secrets.token_urlsafe(64))"
|
|
|
|
cd frontend; npm ci; npm run build; cd ..
|
|
|
|
docker compose -f docker-compose.prebuilt.yml -f docker-compose.backup.yml --profile backup build
|
|
docker compose -f docker-compose.prebuilt.yml -f docker-compose.backup.yml --profile backup up -d
|
|
```
|
|
|
|
The `migrate` service runs the schema, the plugin bootstrap and the seeders
|
|
before `api` starts, so there is no separate migration step. Watch it with
|
|
`docker compose logs migrate`.
|
|
|
|
Create the first admin at `https://localhost:5001/setup`, or headlessly:
|
|
|
|
```powershell
|
|
docker compose exec api flask seed admin --username admin --email admin@example.com
|
|
```
|
|
|
|
The password is generated and printed once.
|
|
|
|
## Step 3: Reach it from the host
|
|
|
|
```powershell
|
|
New-NetFirewallRule -DisplayName "ShopDB" -Direction Inbound -LocalPort 5001 -Protocol TCP -Action Allow
|
|
```
|
|
|
|
Then `https://<vm-ip>:5001` from the host. The certificate is self-signed until
|
|
you replace the pair in `certs/`, so the browser warns; that is expected on a
|
|
VM.
|
|
|
|
`CORS_ORIGINS` is an exact origin match, so it has to name the address the
|
|
browser really uses. Reaching the VM by IP while `CORS_ORIGINS` names
|
|
`localhost` is the usual cause of "the page loads and every request fails".
|
|
|
|
## About `deploy-to-vm.ps1`
|
|
|
|
The repository root carries `deploy-to-vm.ps1`, which wraps the above into eight
|
|
steps with `-SiteName` and `-AdminPassword` parameters. **Read it before you run
|
|
it.** As it stands it does not work on a clean clone, and neither problem is
|
|
subtle:
|
|
|
|
- It copies `.env.docker-dev` to create `.env`. That file is not in the
|
|
repository, so step 3 fails on a fresh checkout. Create `.env` from
|
|
`.env.example` yourself first and the script skips that branch.
|
|
- It addresses containers by the fixed names `flask-shopdb-api-1` and
|
|
`flask-shopdb-db-1`. Compose names containers after the project, which is the
|
|
directory name, so on a clone called `shopdb` those `docker exec` calls
|
|
miss. Use `docker compose exec api` instead, or `docker compose ps` to see
|
|
the real names.
|
|
|
|
It also runs only `flask db upgrade` for the database, which predates the
|
|
`migrate` service and is now redundant rather than wrong.
|
|
|
|
Its default `-AdminPassword` is a literal in the file and therefore public.
|
|
Pass your own, and never leave the default on anything reachable.
|
|
|
|
## Stop, start, update
|
|
|
|
```bash
|
|
docker compose -f docker-compose.prebuilt.yml -f docker-compose.backup.yml down
|
|
docker compose -f docker-compose.prebuilt.yml -f docker-compose.backup.yml --profile backup up -d
|
|
```
|
|
|
|
`down` keeps the volumes. `down -v` deletes them, which is the database and
|
|
`instance/` together, with no prompt.
|
|
|
|
To take new code:
|
|
|
|
```bash
|
|
git pull
|
|
cd frontend; npm run build; cd ..
|
|
docker compose -f docker-compose.prebuilt.yml -f docker-compose.backup.yml build
|
|
docker compose -f docker-compose.prebuilt.yml -f docker-compose.backup.yml up -d
|
|
```
|
|
|
|
Rebuilding the frontend is not optional on the pre-built path: the image copies
|
|
whatever is in `frontend/dist/`, so a skipped `npm run build` ships the old UI
|
|
with no warning.
|
|
|
|
## Why this works with no network
|
|
|
|
With `frontend/dist/` already built and the Python wheels vendored, the image
|
|
build downloads nothing, which is what makes the same procedure the rehearsal
|
|
for [DEPLOY-AIRGAP](../DEPLOY-AIRGAP.md).
|