Allow Running Container as Runner Host User (#600)

- Added `runAsHostUser` to allow running the container as the same user as the host system. This fixes most permissions issues on self-hosted runners.
- Perform android sdk setup during entrypoint.sh to ensure it has root permissions if the user switches to a non-root user
- Automatically detect android sdk target version if parameters are not already provided to configure the sdk
- Generate a new uuid for machineID to ensure separate containers are unique to reduce license activation errors
- Add exponential retry strategy for Ubuntu license activations
This commit is contained in:
Andrew Kahr
2023-11-24 23:24:16 -08:00
committed by GitHub
parent 8da77ace98
commit 8ca1282c9e
15 changed files with 176 additions and 99 deletions

View File

@@ -59,6 +59,7 @@ class BuildParameters {
public kubeVolumeSize!: string;
public kubeVolume!: string;
public kubeStorageClass!: string;
public runAsHostUser!: String;
public chownFilesTo!: string;
public commandHooks!: string;
public pullInputList!: string[];
@@ -168,6 +169,7 @@ class BuildParameters {
sshAgent: Input.sshAgent,
sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath,
gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()),
runAsHostUser: Input.runAsHostUser,
chownFilesTo: Input.chownFilesTo,
dockerCpuLimit: Input.dockerCpuLimit,
dockerMemoryLimit: Input.dockerMemoryLimit,

View File

@@ -62,6 +62,7 @@ class ImageEnvironmentFactory {
{ name: 'ANDROID_EXPORT_TYPE', value: parameters.androidExportType },
{ name: 'ANDROID_SYMBOL_TYPE', value: parameters.androidSymbolType },
{ name: 'CUSTOM_PARAMETERS', value: parameters.customParameters },
{ name: 'RUN_AS_HOST_USER', value: parameters.runAsHostUser },
{ name: 'CHOWN_FILES_TO', value: parameters.chownFilesTo },
{ name: 'GITHUB_REF', value: process.env.GITHUB_REF },
{ name: 'GITHUB_SHA', value: process.env.GITHUB_SHA },

View File

@@ -193,6 +193,10 @@ class Input {
return Input.getInput('gitPrivateToken');
}
static get runAsHostUser(): string {
return Input.getInput('runAsHostUser') || 'false';
}
static get chownFilesTo() {
return Input.getInput('chownFilesTo') || '';
}