From 9c44e6c1dee37300e53b749d10f053be325fbb6a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 7 Jun 2022 09:11:25 +0100 Subject: [PATCH] Cypress: only pass -u arg to docker on *nix systems (#8773) --- cypress/plugins/synapsedocker/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cypress/plugins/synapsedocker/index.ts b/cypress/plugins/synapsedocker/index.ts index 7108ade904..42241ecc7d 100644 --- a/cypress/plugins/synapsedocker/index.ts +++ b/cypress/plugins/synapsedocker/index.ts @@ -112,6 +112,12 @@ async function synapseStart(template: string): Promise { const containerName = `react-sdk-cypress-synapse-${crypto.randomBytes(4).toString("hex")}`; const userInfo = os.userInfo(); + let userParams: string[] = []; + if (userInfo.uid >= 0) { + // On *nix we run the docker container as our uid:gid otherwise cleaning it up its media_store can be difficult + userParams = ["-u", `${userInfo.uid}:${userInfo.gid}`]; + } + const synapseId = await new Promise((resolve, reject) => { childProcess.execFile('docker', [ "run", @@ -119,8 +125,7 @@ async function synapseStart(template: string): Promise { "-d", "-v", `${synCfg.configDir}:/data`, "-p", `${synCfg.port}:8008/tcp`, - // We run the docker container as our uid:gid otherwise cleaning it up its media_store can be difficult - "-u", `${userInfo.uid}:${userInfo.gid}`, + ...userParams, "matrixdotorg/synapse:develop", "run", ], (err, stdout) => {