PlotDirector/Docs/Codex/Deployment.md

94 lines
3.2 KiB
Markdown

# PlotDirector Development Deployment
Read this document only when deployment or detailed development-service operation is part of the task.
## Environment
- Development host: Atlas.
- Repository: `/srv/repos/PlotDirector`.
- Development files: `/srv/apps/plotdirector-dev/current`.
- Release archive: `/srv/apps/plotdirector-dev/releases/`.
- Service: `plotdirector-dev`.
- Service user: `plotdirector:plotdirector`.
- Environment file: `/etc/plotdirector/plotdirector.env`.
- Persistent uploads: `/srv/apps/plotdirector-dev/uploads`.
- Default deployed data-protection keys: `/srv/apps/plotdirector-dev/App_Data/DataProtectionKeys`.
- Local endpoint: `http://127.0.0.1:5050`.
- Public development endpoint: `https://dev.plotdirector.com/`.
`current` is a physical directory, not a symlink.
Use `sudo -n` for protected service/configuration paths where appropriate.
## Before Deployment
Confirm the intended commit:
git status --short --branch
git log -1 --oneline
If the change involves database migration, apply and verify required SQL before deploying dependent code.
Before stopping the service, confirm there is no active import, Story Intelligence run, synthesis or character enrichment work. Check queued and processing work as well as core imports.
Do not deploy while such work is active unless interruption has explicitly been accepted.
## Publish
Use a fresh temporary publish directory. Set fail-fast shell behaviour and derive a release name from the short commit SHA and UTC timestamp.
Publish with:
dotnet publish PlotLine/PlotLine.csproj -c Release -o "$publish_dir"
The standard paths are:
release_dir="/srv/apps/plotdirector-dev/releases/$release"
backup_dir="/srv/apps/plotdirector-dev/current-before-$release"
## Install
Copy the fresh publish into the release archive and ensure ownership is `plotdirector:plotdirector`.
Stop `plotdirector-dev` before replacing the physical live directory.
Back up the existing `current` directory to the timestamped `current-before` path.
Use `rsync -a --delete` from the release directory into `current`, preserving:
- `appsettings*.json`
- `.env*`
- `App_Data/`
- `wwwroot/uploads/`
- `uploads/`
- `logs/`
- `Logs/`
Restore `plotdirector:plotdirector` ownership and start `plotdirector-dev`.
If installation or startup fails, stop and diagnose. Do not continue blindly or claim successful deployment.
An application rollback does not undo SQL migrations and must remain compatible with the migrated schema.
## Verification
Verify:
- `systemctl is-active plotdirector-dev`
- service status and recent warning/error logs;
- local GET to `http://127.0.0.1:5050/`;
- public HTTPS GET to `https://dev.plotdirector.com/`;
- deployed `PlotLine.dll` metadata;
- SHA-256 of published and deployed `PlotLine.dll`;
- the changed authenticated route when applicable.
Timestamps alone do not prove the intended build is running.
Use a real GET for public smoke testing. HEAD may return 405.
Normal verification must validate TLS. Use `-k` only for certificate diagnosis.
Review configuration changes separately because deployment preserves deployed appsettings files.
Keep the release directory and `current-before` backup named with the deployed short SHA and UTC timestamp for traceability.