Switch to process isolation mode by default and give an option to use hyperv isolation to improve performance

pull/588/head
Andrew Kahr 2023-10-27 18:55:23 -07:00
parent d47dc754af
commit 974b785700
5 changed files with 17 additions and 2 deletions

View File

@ -117,6 +117,11 @@ inputs:
'Amount of memory to assign the docker container. Defaults to 95% of total system memory rounded down to the 'Amount of memory to assign the docker container. Defaults to 95% of total system memory rounded down to the
nearest megabyte on Linux and 80% on Windows. On unrecognized platforms, defaults to 75% of total system memory. nearest megabyte on Linux and 80% on Windows. On unrecognized platforms, defaults to 75% of total system memory.
To manually specify a value, use the format <number><unit>, where unit is either m or g. ie: 512m = 512 megabytes' To manually specify a value, use the format <number><unit>, where unit is either m or g. ie: 512m = 512 megabytes'
dockerIsolationMode:
required: false
default: 'process'
description:
'Isolation mode to use for the docker container. Can be either process or hyperv. Only applicable on Windows'
allowDirtyBuild: allowDirtyBuild:
required: false required: false
default: '' default: ''

6
dist/index.js generated vendored
View File

@ -5925,7 +5925,7 @@ class Docker {
"${overrideCommands !== '' ? overrideCommands : `/entrypoint.sh`}"`; "${overrideCommands !== '' ? overrideCommands : `/entrypoint.sh`}"`;
} }
static getWindowsCommand(image, parameters) { static getWindowsCommand(image, parameters) {
const { workspace, actionFolder, unitySerial, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, } = parameters; const { workspace, actionFolder, unitySerial, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, dockerIsolationMode, } = parameters;
return `docker run \ return `docker run \
--workdir c:${dockerWorkspacePath} \ --workdir c:${dockerWorkspacePath} \
--rm \ --rm \
@ -5944,6 +5944,7 @@ class Docker {
--volume "${actionFolder}/BlankProject":"c:/BlankProject" \ --volume "${actionFolder}/BlankProject":"c:/BlankProject" \
--cpus=${dockerCpuLimit} \ --cpus=${dockerCpuLimit} \
--memory=${dockerMemoryLimit} \ --memory=${dockerMemoryLimit} \
--isolation=${dockerIsolationMode} \
${image} \ ${image} \
powershell c:/steps/entrypoint.ps1`; powershell c:/steps/entrypoint.ps1`;
} }
@ -6934,6 +6935,9 @@ class Input {
} }
return (Input.getInput('dockerMemoryLimit') || `${Math.floor((node_os_1.default.totalmem() / bytesInMegabyte) * memoryMultiplier)}m`); return (Input.getInput('dockerMemoryLimit') || `${Math.floor((node_os_1.default.totalmem() / bytesInMegabyte) * memoryMultiplier)}m`);
} }
static get dockerIsolationMode() {
return Input.getInput('dockerIsolationMode') || 'process';
}
static ToEnvVarFormat(input) { static ToEnvVarFormat(input) {
if (input.toUpperCase() === input) { if (input.toUpperCase() === input) {
return input; return input;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -98,6 +98,7 @@ class Docker {
dockerWorkspacePath, dockerWorkspacePath,
dockerCpuLimit, dockerCpuLimit,
dockerMemoryLimit, dockerMemoryLimit,
dockerIsolationMode,
} = parameters; } = parameters;
return `docker run \ return `docker run \
@ -118,6 +119,7 @@ class Docker {
--volume "${actionFolder}/BlankProject":"c:/BlankProject" \ --volume "${actionFolder}/BlankProject":"c:/BlankProject" \
--cpus=${dockerCpuLimit} \ --cpus=${dockerCpuLimit} \
--memory=${dockerMemoryLimit} \ --memory=${dockerMemoryLimit} \
--isolation=${dockerIsolationMode} \
${image} \ ${image} \
powershell c:/steps/entrypoint.ps1`; powershell c:/steps/entrypoint.ps1`;
} }

View File

@ -252,6 +252,10 @@ class Input {
); );
} }
static get dockerIsolationMode(): string {
return Input.getInput('dockerIsolationMode') || 'process';
}
public static ToEnvVarFormat(input: string) { public static ToEnvVarFormat(input: string) {
if (input.toUpperCase() === input) { if (input.toUpperCase() === input) {
return input; return input;