Skip to content

Commit 723fc1f

Browse files
author
DavidQ
committed
Standardizes environment configuration handling for Docker deployment scripts.
BUILD_PR_LEVEL_09_27_DEPLOY_ENV_CONFIG_STANDARDIZATION
1 parent bf15a81 commit 723fc1f

11 files changed

Lines changed: 345 additions & 39 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ MODEL: GPT-5.4
22
REASONING: high
33

44
COMMAND:
5-
- add dry-run mode to scripts/PS/deploy/
6-
- validate inputs and environment
7-
- prevent destructive execution without explicit confirmation
8-
- improve output messaging
5+
- standardize env config handling for scripts/PS/deploy/
6+
- support .env loading
7+
- normalize variable names
8+
- ensure consistent config usage
99
- commit format:
1010
description first line
1111
PR name last line

docs/dev/COMMIT_COMMENT.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Add deploy dry-run/environment validation guards and require explicit destructive confirmation for apply cleanup/refresh paths.
2-
BUILD_PR_LEVEL_09_26_DEPLOY_VALIDATION_AND_DRYRUN
1+
Standardize deploy env config via shared .env loading, normalized DEPLOY_* variables, and consistent script-level config resolution.
2+
BUILD_PR_LEVEL_09_27_DEPLOY_ENV_CONFIG_STANDARDIZATION

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD_PR_LEVEL_09_27_DEPLOY_ENV_CONFIG_STANDARDIZATION
1+
BUILD_PR_LEVEL_09_28_DEPLOY_EXECUTION_WRAPPER
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
BUILD_PR_LEVEL_09_26_DEPLOY_VALIDATION_AND_DRYRUN
1+
BUILD_PR_LEVEL_09_27_DEPLOY_ENV_CONFIG_STANDARDIZATION
22

33
Scope:
4-
- Refined deployment safety/validation behavior only under `scripts/PS/deploy/`.
5-
- No runtime, engine, tool UI, or non-deploy scope changes.
4+
- Standardized deploy-script environment configuration only under `scripts/PS/deploy/`.
5+
- No runtime, engine, tool UI, or non-deploy behavior expansion.
66

77
Implemented:
8-
- Kept/standardized dry-run behavior across deploy scripts with clearer next-step messaging.
9-
- Added environment readiness validation (`repo root`, `tmp root`, staging-root containment) before execution.
10-
- Added include-path contract validation (repo-relative only, no traversal/wildcards/rooted paths).
11-
- Added explicit destructive confirmation guard via `-ConfirmDestructive` for:
12-
- `Update-WebsiteRepoDeployment.ps1` apply path (site-root refresh/delete)
13-
- `Clean-WebsiteRepoDeployment.ps1` apply path (artifact deletion)
14-
- Preserved non-destructive defaults and existing staging-root safety checks.
8+
- Added shared `.env` loading in `WebsiteRepoDeploymentCommon.ps1` with repo-root default and optional `-EnvFilePath` override.
9+
- Added normalized deploy env variables:
10+
- `DEPLOY_STAGING_ROOT`
11+
- `DEPLOY_INCLUDE_PATHS`
12+
- `DEPLOY_REMOVE_METADATA`
13+
- `DEPLOY_WEB_PORT`
14+
- Added backward-compat alias handling (`STAGING_ROOT`, `INCLUDE_PATHS`, `REMOVE_METADATA`, `PORT`) with warning logs.
15+
- Centralized script config resolution via `Resolve-DeployScriptConfig` so prep/update/clean all load config the same way.
16+
- Added config-load telemetry (`Write-DeployConfigLoadLog`) for consistent operator visibility.
17+
- Updated docker compose artifact generation to use normalized variable token `${DEPLOY_WEB_PORT:-<default>}`.
18+
- Added optional `-EnvFilePath` on prep/update/clean and optional `-WebPort` override on prep/update.
1519

16-
Tracking:
17-
- Commit comment format enforced (description first line, PR name last line, no leading blank line).
18-
- Roadmap updated with status-only change.
20+
Result:
21+
- Deploy scripts now use one consistent config contract with deterministic precedence:
22+
explicit params > `.env` values > built-in defaults.
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
[x] PowerShell parse/readiness checks pass on touched deploy scripts
2-
[x] Dry-run smoke checks pass for prep/update/clean deploy scripts
3-
[x] Environment readiness validation executes before deploy operations
4-
[x] Invalid include path traversal input is rejected
5-
[x] Update apply is blocked without explicit -ConfirmDestructive
6-
[x] Clean apply is blocked without explicit -ConfirmDestructive
7-
[x] Update/Clean apply succeed when -ConfirmDestructive is provided
2+
[x] .env loading works through shared config resolver for prep/update/clean
3+
[x] Normalized DEPLOY_* variables resolve consistently across deploy scripts
4+
[x] Legacy env aliases still work and emit warning telemetry
5+
[x] Docker compose output uses normalized DEPLOY_WEB_PORT token and resolved default
6+
[x] Dry-run/apply focused smoke checks pass with .env-sourced config
87
[x] Script structure validation smoke run passes
98
[x] Roadmap updated with status-only change

docs/dev/roadmaps/MASTER_ROADMAP_HIGH_LEVEL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@
573573
- [x] reports structure established
574574
- [x] templates structure established
575575
- [x] roadmaps folder recognized as tracker space
576-
- [.] master roadmap committed and maintained
576+
- [x] master roadmap committed and maintained
577577
- [ ] per-component roadmap slices added only when truly needed
578578
- [ ] structure normalization roadmap linked to future BUILD lanes
579579
- [ ] phase descriptions normalized repo-wide
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# BUILD_PR — LEVEL 09_27 — DEPLOY ENV CONFIG STANDARDIZATION
2+
3+
## Objective
4+
Standardize environment configuration handling for Docker deployment scripts.
5+
6+
## Scope
7+
- unify environment variable handling
8+
- support .env files
9+
- ensure consistent config loading across deploy scripts
10+
11+
## Out of Scope
12+
- no runtime changes
13+
- no tool UI changes
14+
15+
## Roadmap Instruction
16+
- Update roadmap status only

scripts/PS/deploy/Clean-WebsiteRepoDeployment.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
param(
33
[string]$StagingRoot,
44
[switch]$RemoveMetadata,
5+
[string]$EnvFilePath,
56
[switch]$Apply,
67
[switch]$DryRun,
78
[switch]$ConfirmDestructive
@@ -13,16 +14,19 @@ $ErrorActionPreference = "Stop"
1314
. (Join-Path $PSScriptRoot "WebsiteRepoDeploymentCommon.ps1")
1415
Assert-DeployScriptLocation -ScriptPath $PSCommandPath
1516
$executionMode = Resolve-DeployExecutionMode -Apply:$Apply.IsPresent -DryRun:$DryRun.IsPresent
17+
$resolvedRemoveMetadata = if ($PSBoundParameters.ContainsKey("RemoveMetadata")) { [Nullable[bool]]$RemoveMetadata.IsPresent } else { $null }
18+
$config = Resolve-DeployScriptConfig -StagingRoot $StagingRoot -RemoveMetadata $resolvedRemoveMetadata -EnvFilePath $EnvFilePath
19+
Write-DeployConfigLoadLog -ScriptName "Clean-WebsiteRepoDeployment" -Config $config
1620

17-
$paths = Get-WebsiteDeploymentPaths -StagingRoot $StagingRoot
21+
$paths = Get-WebsiteDeploymentPaths -StagingRoot $config.stagingRoot
1822
Test-StagingRootSafety -StagingRoot $paths.stagingRoot
1923
$environment = Assert-DeployEnvironmentReadiness -Paths $paths
2024

2125
$targets = New-Object System.Collections.Generic.List[string]
2226
if (Test-Path -LiteralPath $paths.siteRoot) {
2327
$targets.Add($paths.siteRoot)
2428
}
25-
if ($RemoveMetadata.IsPresent) {
29+
if ($config.removeMetadata) {
2630
foreach ($metadataPath in @($paths.planPath, $paths.updateReportPath, $paths.dockerfilePath, $paths.composePath, $paths.dockerIgnorePath)) {
2731
if (Test-Path -LiteralPath $metadataPath) {
2832
$targets.Add($metadataPath)
@@ -34,6 +38,7 @@ if ($targets.Count -eq 0) {
3438
Write-DeployLog -Level "INFO" -Message "Nothing to clean." -Data @{
3539
script = "Clean-WebsiteRepoDeployment"
3640
stagingRoot = $paths.stagingRoot
41+
removeMetadata = $config.removeMetadata
3742
}
3843
exit 0
3944
}
@@ -46,6 +51,7 @@ if ($executionMode.isDryRun) {
4651
targets = @($targets)
4752
dockerCliFound = $environment.dockerCliFound
4853
destructiveConfirmationRequired = $true
54+
removeMetadata = $config.removeMetadata
4955
}
5056
Write-DeployLog -Level "INFO" -Message "Next step: run Clean-WebsiteRepoDeployment.ps1 -Apply -ConfirmDestructive after reviewing the dry-run output."
5157
exit 0
@@ -68,4 +74,5 @@ Write-DeployLog -Level "SUCCESS" -Message "Cleaned website deployment artifacts.
6874
mode = $executionMode.label
6975
targetCount = $targets.Count
7076
dockerCliFound = $environment.dockerCliFound
77+
removeMetadata = $config.removeMetadata
7178
}

scripts/PS/deploy/Prep-WebsiteRepoDeployment.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
param(
33
[string]$StagingRoot,
44
[string[]]$IncludePaths,
5+
[int]$WebPort,
6+
[string]$EnvFilePath,
57
[switch]$Apply,
68
[switch]$DryRun
79
)
@@ -12,13 +14,16 @@ $ErrorActionPreference = "Stop"
1214
. (Join-Path $PSScriptRoot "WebsiteRepoDeploymentCommon.ps1")
1315
Assert-DeployScriptLocation -ScriptPath $PSCommandPath
1416
$executionMode = Resolve-DeployExecutionMode -Apply:$Apply.IsPresent -DryRun:$DryRun.IsPresent
17+
$resolvedWebPort = if ($PSBoundParameters.ContainsKey("WebPort")) { [Nullable[int]]$WebPort } else { $null }
18+
$config = Resolve-DeployScriptConfig -StagingRoot $StagingRoot -IncludePaths $IncludePaths -WebPort $resolvedWebPort -EnvFilePath $EnvFilePath
19+
Write-DeployConfigLoadLog -ScriptName "Prep-WebsiteRepoDeployment" -Config $config
1520

1621
$repoRoot = Get-DeployRepoRoot
17-
$paths = Get-WebsiteDeploymentPaths -StagingRoot $StagingRoot
22+
$paths = Get-WebsiteDeploymentPaths -StagingRoot $config.stagingRoot
1823
Test-StagingRootSafety -StagingRoot $paths.stagingRoot
1924
$environment = Assert-DeployEnvironmentReadiness -Paths $paths
2025

21-
$normalizedIncludePaths = Normalize-IncludePaths -IncludePaths $IncludePaths
26+
$normalizedIncludePaths = Normalize-IncludePaths -IncludePaths $config.includePaths
2227
if ($normalizedIncludePaths.Count -eq 0) {
2328
$normalizedIncludePaths = Get-DefaultWebsiteIncludePaths
2429
}
@@ -64,7 +69,7 @@ Ensure-Directory -Path $paths.stagingRoot
6469
Ensure-Directory -Path $paths.siteRoot
6570
Ensure-Directory -Path $paths.metaRoot
6671
Write-JsonFile -Value $plan -Path $paths.planPath
67-
Write-DockerDeploymentArtifacts -Paths $paths
72+
Write-DockerDeploymentArtifacts -Paths $paths -WebPort $config.webPort
6873
Assert-DockerArtifactReadiness -Paths $paths
6974

7075
Write-DeployLog -Level "SUCCESS" -Message "Prepared website deployment staging." -Data @{
@@ -74,4 +79,5 @@ Write-DeployLog -Level "SUCCESS" -Message "Prepared website deployment staging."
7479
planPath = $paths.planPath
7580
dockerfilePath = $paths.dockerfilePath
7681
dockerCliFound = $environment.dockerCliFound
82+
webPort = $config.webPort
7783
}

scripts/PS/deploy/Update-WebsiteRepoDeployment.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
param(
33
[string]$StagingRoot,
44
[string[]]$IncludePaths,
5+
[int]$WebPort,
6+
[string]$EnvFilePath,
57
[switch]$Apply,
68
[switch]$DryRun,
79
[switch]$ConfirmDestructive
@@ -13,13 +15,16 @@ $ErrorActionPreference = "Stop"
1315
. (Join-Path $PSScriptRoot "WebsiteRepoDeploymentCommon.ps1")
1416
Assert-DeployScriptLocation -ScriptPath $PSCommandPath
1517
$executionMode = Resolve-DeployExecutionMode -Apply:$Apply.IsPresent -DryRun:$DryRun.IsPresent
18+
$resolvedWebPort = if ($PSBoundParameters.ContainsKey("WebPort")) { [Nullable[int]]$WebPort } else { $null }
19+
$config = Resolve-DeployScriptConfig -StagingRoot $StagingRoot -IncludePaths $IncludePaths -WebPort $resolvedWebPort -EnvFilePath $EnvFilePath
20+
Write-DeployConfigLoadLog -ScriptName "Update-WebsiteRepoDeployment" -Config $config
1621

1722
$repoRoot = Get-DeployRepoRoot
18-
$paths = Get-WebsiteDeploymentPaths -StagingRoot $StagingRoot
23+
$paths = Get-WebsiteDeploymentPaths -StagingRoot $config.stagingRoot
1924
Test-StagingRootSafety -StagingRoot $paths.stagingRoot
2025
$environment = Assert-DeployEnvironmentReadiness -Paths $paths
2126

22-
$normalizedIncludePaths = Normalize-IncludePaths -IncludePaths $IncludePaths
27+
$normalizedIncludePaths = Normalize-IncludePaths -IncludePaths $config.includePaths
2328
if ($normalizedIncludePaths.Count -eq 0) {
2429
if (Test-Path -LiteralPath $paths.planPath) {
2530
$existingPlan = Read-JsonFile -Path $paths.planPath
@@ -97,7 +102,7 @@ foreach ($entry in $copyEntries) {
97102

98103
$plan = New-WebsiteDeploymentPlan -IncludePaths $normalizedIncludePaths -RepoRoot $repoRoot
99104
Write-JsonFile -Value $plan -Path $paths.planPath
100-
Write-DockerDeploymentArtifacts -Paths $paths
105+
Write-DockerDeploymentArtifacts -Paths $paths -WebPort $config.webPort
101106
Assert-DockerArtifactReadiness -Paths $paths
102107

103108
$report = [ordered]@{
@@ -120,4 +125,5 @@ Write-DeployLog -Level "SUCCESS" -Message "Updated website deployment staging co
120125
dockerfilePath = $paths.dockerfilePath
121126
reportPath = $paths.updateReportPath
122127
dockerCliFound = $environment.dockerCliFound
128+
webPort = $config.webPort
123129
}

0 commit comments

Comments
 (0)