forked from mtusi2026/mtusi2026lab4
32 lines
1.4 KiB
PowerShell
32 lines
1.4 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
Push-Location (Split-Path -Parent $PSScriptRoot)
|
|
try {
|
|
function Invoke-Compose {
|
|
Write-Output ('COMMAND: docker compose --env-file .env ' + ($args -join ' '))
|
|
& docker compose --env-file .env @args
|
|
if ($LASTEXITCODE -ne 0) { throw "Compose failed with exit code $LASTEXITCODE" }
|
|
}
|
|
./scripts/init-local.ps1
|
|
Invoke-Compose build s3 s3-bootstrap
|
|
Invoke-Compose up -d s3
|
|
Invoke-Compose run --rm s3-bootstrap
|
|
Invoke-Compose run --rm --entrypoint /bin/sh s3-bootstrap /bootstrap/verify.sh seed
|
|
# Repeat setup after a real object exists, then restart its storage process.
|
|
Invoke-Compose run --rm s3-bootstrap
|
|
Invoke-Compose restart s3
|
|
Invoke-Compose run --rm s3-bootstrap
|
|
Invoke-Compose run --rm --entrypoint /bin/sh s3-bootstrap /bootstrap/verify.sh check
|
|
$container = & docker compose ps -q s3
|
|
if ($LASTEXITCODE -ne 0 -or -not $container) { throw 'S3 container not found' }
|
|
$portsJson = & docker inspect --format '{{json .NetworkSettings.Ports}}' $container
|
|
if ($LASTEXITCODE -ne 0) { throw 'Cannot inspect published ports' }
|
|
$ports = $portsJson | ConvertFrom-Json
|
|
foreach ($property in $ports.PSObject.Properties) {
|
|
if ($null -ne $property.Value) { throw 'Unexpected published S3 port' }
|
|
}
|
|
Write-Output 'PASS: S3 has no published host ports.'
|
|
Write-Output 'PASS: S3 infrastructure checks completed.'
|
|
} finally {
|
|
Pop-Location
|
|
}
|