Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Cypress: only pass -u arg to docker on *nix systems (#8773)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Jun 7, 2022
1 parent fa8c346 commit 9c44e6c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cypress/plugins/synapsedocker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,20 @@ async function synapseStart(template: string): Promise<SynapseInstance> {
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<string>((resolve, reject) => {
childProcess.execFile('docker', [
"run",
"--name", containerName,
"-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) => {
Expand Down

0 comments on commit 9c44e6c

Please sign in to comment.