@@ -8,6 +8,9 @@ $spikeRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
88$runtimeRoot = Join-Path $spikeRoot ' runtime'
99$certRoot = Join-Path $runtimeRoot ' certs'
1010$synapseImage = ' matrixdotorg/synapse:v1.157.0@sha256:53a686c52cdfca5fdb0adff5ef10b276b1d0971931b09815a9eb6b48d7188a1a'
11+ $runningOnWindows = [System.Runtime.InteropServices.RuntimeInformation ]::IsOSPlatform(
12+ [System.Runtime.InteropServices.OSPlatform ]::Windows
13+ )
1114
1215if ($Reset ) {
1316 Push-Location $spikeRoot
@@ -79,9 +82,29 @@ function Ensure-SynapseConfig {
7982 New-Item - ItemType Directory - Force - Path $dataPath | Out-Null
8083 $configPath = Join-Path $dataPath ' homeserver.yaml'
8184 if (-not (Test-Path - LiteralPath $configPath )) {
82- & docker run -- rm - v " ${dataPath} :/data" `
83- - e " SYNAPSE_SERVER_NAME=$ServerName " - e SYNAPSE_REPORT_STATS= no `
84- $synapseImage generate
85+ $dockerRunArguments = @ (' run' , ' --rm' )
86+ if (-not $runningOnWindows ) {
87+ $userId = (& id - u).Trim()
88+ if ($LASTEXITCODE -ne 0 -or $userId -notmatch ' ^\d+$' ) {
89+ throw ' Could not determine the Unix user ID for Matrix spike setup'
90+ }
91+ $groupId = (& id - g).Trim()
92+ if ($LASTEXITCODE -ne 0 -or $groupId -notmatch ' ^\d+$' ) {
93+ throw ' Could not determine the Unix group ID for Matrix spike setup'
94+ }
95+ $dockerRunArguments += @ (' --user' , " ${userId} :${groupId} " )
96+ }
97+ $dockerRunArguments += @ (
98+ ' -v' ,
99+ " ${dataPath} :/data" ,
100+ ' -e' ,
101+ " SYNAPSE_SERVER_NAME=$ServerName " ,
102+ ' -e' ,
103+ ' SYNAPSE_REPORT_STATS=no' ,
104+ $synapseImage ,
105+ ' generate'
106+ )
107+ & docker @dockerRunArguments
85108 if ($LASTEXITCODE -ne 0 ) { throw " Failed to generate Synapse config for $ServerName " }
86109
87110 Add-Content - LiteralPath $configPath - Value @"
@@ -141,6 +164,22 @@ allow_public_rooms_over_federation: true
141164"@
142165 }
143166 Copy-Item - LiteralPath $caCert - Destination (Join-Path $dataPath ' test-ca.crt' ) - Force
167+ if (-not $runningOnWindows ) {
168+ # Disposable CI only: the host runner owns setup files while Synapse
169+ # runs as UID 991. Keep the gitignored runtime mutually accessible so
170+ # reset can rewrite it and the container can create its SQLite/media
171+ # state. Production homeserver permissions are configured elsewhere.
172+ & chmod 0777 $dataPath
173+ if ($LASTEXITCODE -ne 0 ) {
174+ throw " Could not grant Synapse write access to $dataPath "
175+ }
176+ foreach ($runtimeFile in Get-ChildItem - LiteralPath $dataPath - File) {
177+ & chmod 0644 $runtimeFile.FullName
178+ if ($LASTEXITCODE -ne 0 ) {
179+ throw " Could not grant Synapse read access to $ ( $runtimeFile.FullName ) "
180+ }
181+ }
182+ }
144183}
145184
146185Ensure- SynapseConfig - DirectoryName ' hs1' - ServerName ' hs1.mesh.test' - HostPort 8008
0 commit comments