|
1 | 1 | # Codex Website Repo Deployment Scripting |
2 | 2 |
|
3 | | -Use these scripts from `scripts/PS/deploy/` to stage repo content for website deployment with safe defaults and Docker compatibility artifacts. |
| 3 | +This document is the operator handoff for the Docker-based website staging flow under `scripts/PS/deploy/`. |
4 | 4 |
|
5 | | -## Scripts |
| 5 | +## Script Roles |
6 | 6 | - `scripts/PS/deploy/Prep-WebsiteRepoDeployment.ps1` |
| 7 | + - prepares staging folders |
| 8 | + - writes plan + docker artifacts |
7 | 9 | - `scripts/PS/deploy/Update-WebsiteRepoDeployment.ps1` |
| 10 | + - refreshes staged site content |
| 11 | + - runs post-deploy verification by default |
| 12 | + - supports controlled rollback behavior |
8 | 13 | - `scripts/PS/deploy/Clean-WebsiteRepoDeployment.ps1` |
| 14 | + - removes staged output |
| 15 | + - optionally removes metadata + ops artifacts |
9 | 16 |
|
10 | 17 | ## Safety Defaults |
11 | | -- All scripts default to dry-run mode. |
12 | | -- No files are written or deleted unless `-Apply` is provided. |
13 | | -- `-DryRun` is available explicitly on each script. |
14 | | -- Clean operations are restricted to staging paths under `<repo>/tmp`. |
| 18 | +- scripts default to dry-run when `-Apply` is not provided |
| 19 | +- destructive paths require explicit confirmation (`-ConfirmDestructive`) |
| 20 | +- staging is restricted under `<repo>/tmp` |
| 21 | +- update verification failures abort by default |
15 | 22 |
|
16 | | -## Typical Flow |
17 | | -Prepare staging plan and Docker artifacts: |
| 23 | +## Config Contract |
| 24 | +Config precedence is: |
| 25 | +1. explicit script parameters |
| 26 | +2. `.env` (or `-EnvFilePath`) |
| 27 | +3. built-in defaults |
| 28 | + |
| 29 | +Normalized deploy env names: |
| 30 | +- `DEPLOY_STAGING_ROOT` |
| 31 | +- `DEPLOY_INCLUDE_PATHS` |
| 32 | +- `DEPLOY_REMOVE_METADATA` |
| 33 | +- `DEPLOY_WEB_PORT` |
| 34 | + |
| 35 | +Legacy aliases are still accepted with warning logs: |
| 36 | +- `STAGING_ROOT`, `INCLUDE_PATHS`, `REMOVE_METADATA`, `PORT` |
| 37 | + |
| 38 | +## Full Flow (Quick Start) |
| 39 | +1. Validate script structure placement: |
| 40 | + |
| 41 | +```powershell |
| 42 | +.\scripts\PS\validate\Validate-ScriptStructure.ps1 |
| 43 | +``` |
| 44 | + |
| 45 | +2. Preview prep plan: |
| 46 | + |
| 47 | +```powershell |
| 48 | +.\scripts\PS\deploy\Prep-WebsiteRepoDeployment.ps1 -DryRun |
| 49 | +``` |
| 50 | + |
| 51 | +3. Apply prep: |
18 | 52 |
|
19 | 53 | ```powershell |
20 | 54 | .\scripts\PS\deploy\Prep-WebsiteRepoDeployment.ps1 -Apply |
21 | 55 | ``` |
22 | 56 |
|
23 | | -Update staged website content: |
| 57 | +4. Preview update: |
| 58 | + |
| 59 | +```powershell |
| 60 | +.\scripts\PS\deploy\Update-WebsiteRepoDeployment.ps1 -DryRun |
| 61 | +``` |
| 62 | + |
| 63 | +5. Apply update with explicit destructive confirmation: |
24 | 64 |
|
25 | 65 | ```powershell |
26 | | -.\scripts\PS\deploy\Update-WebsiteRepoDeployment.ps1 -Apply |
| 66 | +.\scripts\PS\deploy\Update-WebsiteRepoDeployment.ps1 -Apply -ConfirmDestructive |
27 | 67 | ``` |
28 | 68 |
|
29 | | -Clean staged site output only: |
| 69 | +6. Preview cleanup: |
| 70 | + |
| 71 | +```powershell |
| 72 | +.\scripts\PS\deploy\Clean-WebsiteRepoDeployment.ps1 -DryRun |
| 73 | +``` |
| 74 | + |
| 75 | +7. Apply cleanup with metadata removal: |
| 76 | + |
| 77 | +```powershell |
| 78 | +.\scripts\PS\deploy\Clean-WebsiteRepoDeployment.ps1 -Apply -ConfirmDestructive -RemoveMetadata |
| 79 | +``` |
| 80 | + |
| 81 | +## Example Using `.env` |
| 82 | +Example `tmp/deploy.env`: |
| 83 | + |
| 84 | +```dotenv |
| 85 | +DEPLOY_STAGING_ROOT=tmp/website-deploy-ops |
| 86 | +DEPLOY_INCLUDE_PATHS=index.html,src,tools |
| 87 | +DEPLOY_WEB_PORT=9090 |
| 88 | +DEPLOY_REMOVE_METADATA=true |
| 89 | +``` |
| 90 | + |
| 91 | +Use it across all scripts: |
| 92 | + |
| 93 | +```powershell |
| 94 | +.\scripts\PS\deploy\Prep-WebsiteRepoDeployment.ps1 -EnvFilePath tmp/deploy.env -Apply |
| 95 | +.\scripts\PS\deploy\Update-WebsiteRepoDeployment.ps1 -EnvFilePath tmp/deploy.env -Apply -ConfirmDestructive |
| 96 | +.\scripts\PS\deploy\Clean-WebsiteRepoDeployment.ps1 -EnvFilePath tmp/deploy.env -Apply -ConfirmDestructive |
| 97 | +``` |
| 98 | + |
| 99 | +## Dry-Run + Validation Usage |
| 100 | +Dry-run every stage first: |
| 101 | + |
| 102 | +```powershell |
| 103 | +.\scripts\PS\deploy\Prep-WebsiteRepoDeployment.ps1 -EnvFilePath tmp/deploy.env -DryRun |
| 104 | +.\scripts\PS\deploy\Update-WebsiteRepoDeployment.ps1 -EnvFilePath tmp/deploy.env -DryRun |
| 105 | +.\scripts\PS\deploy\Clean-WebsiteRepoDeployment.ps1 -EnvFilePath tmp/deploy.env -DryRun |
| 106 | +``` |
| 107 | + |
| 108 | +Post-deploy verification output (after update apply): |
| 109 | +- `tmp/<staging>/meta/website-deploy-last-verify.json` |
| 110 | + |
| 111 | +Expected quick checks: |
| 112 | +- `passed` is `true` |
| 113 | +- `failedCheckCount` is `0` |
| 114 | +- required include paths exist under staged `site/` |
| 115 | + |
| 116 | +## Monitoring + Ops Artifacts |
| 117 | +Deploy scripts emit: |
| 118 | +- state file: `meta/website-deploy-ops-state.json` |
| 119 | +- event log: `meta/website-deploy-ops-log.jsonl` |
| 120 | +- verification report: `meta/website-deploy-last-verify.json` |
| 121 | + |
| 122 | +Use these for operator triage: |
| 123 | +- last known stage/status: `website-deploy-ops-state.json` |
| 124 | +- chronological events: `website-deploy-ops-log.jsonl` |
| 125 | +- verification gate result: `website-deploy-last-verify.json` |
| 126 | + |
| 127 | +## Rollback / Abort Expectations |
| 128 | +- default behavior on verification failure: |
| 129 | + - update operation aborts |
| 130 | + - failure details are written to verify report + ops logs |
| 131 | +- optional rollback mode: |
| 132 | + - pass `-RollbackOnVerificationFailure` |
| 133 | + - requires `-ConfirmDestructive` |
| 134 | + - rollback uses cleanup of staged artifacts |
| 135 | + |
| 136 | +Example: |
30 | 137 |
|
31 | 138 | ```powershell |
32 | | -.\scripts\PS\deploy\Clean-WebsiteRepoDeployment.ps1 -Apply |
| 139 | +.\scripts\PS\deploy\Update-WebsiteRepoDeployment.ps1 -Apply -ConfirmDestructive -RollbackOnVerificationFailure |
33 | 140 | ``` |
34 | 141 |
|
35 | | -Clean staged site output plus metadata and Docker files: |
| 142 | +Skip verification only when explicitly needed: |
36 | 143 |
|
37 | 144 | ```powershell |
38 | | -.\scripts\PS\deploy\Clean-WebsiteRepoDeployment.ps1 -RemoveMetadata -Apply |
| 145 | +.\scripts\PS\deploy\Update-WebsiteRepoDeployment.ps1 -Apply -ConfirmDestructive -SkipPostDeployVerification |
39 | 146 | ``` |
40 | 147 |
|
41 | | -## Outputs |
| 148 | +## Output Locations |
42 | 149 | - default staging root: `tmp/website-deploy/` |
43 | | -- staged content root: `tmp/website-deploy/site/` |
| 150 | +- staged site root: `tmp/website-deploy/site/` |
44 | 151 | - metadata root: `tmp/website-deploy/meta/` |
45 | | - - `website-deploy-plan.json` |
46 | | - - `website-deploy-last-update.json` |
47 | | -- docker compatibility files in `tmp/website-deploy/` |
| 152 | +- docker artifacts: |
48 | 153 | - `Dockerfile` |
49 | 154 | - `docker-compose.yml` |
50 | 155 | - `.dockerignore` |
0 commit comments