Skip to content

Commit 9358a3a

Browse files
feat: compatibility with self-hosted runners with SELinux (#355)
* feat: compatibility with self-hosted runners with SELinux When using a self-hosted runner with SELinux (fedora) volumes need to be mounted with ":z" in order to have write access these flags are documented [here](https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label) * Ensure folders are created * use if instead of short circuit * ts convention either inline or use braces * Fix linting * fix linting errors Co-authored-by: Webber Takken <webber.nl@gmail.com>
1 parent d975f3b commit 9358a3a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/model/docker.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { exec } from '@actions/exec';
22
import ImageTag from './image-tag';
33
import ImageEnvironmentFactory from './image-environment-factory';
4+
import { existsSync, mkdirSync } from 'fs';
5+
import path from 'path';
46

57
class Docker {
68
static async build(buildParameters, silent = false) {
7-
const { path, dockerfile, baseImage } = buildParameters;
9+
const { path: buildPath, dockerfile, baseImage } = buildParameters;
810
const { version, platform } = baseImage;
911

1012
const tag = new ImageTag({ repository: '', name: 'unity-builder', version, platform });
11-
const command = `docker build ${path} \
13+
const command = `docker build ${buildPath} \
1214
--file ${dockerfile} \
1315
--build-arg IMAGE=${baseImage} \
1416
--tag ${tag}`;
@@ -41,16 +43,22 @@ class Docker {
4143

4244
static getBaseOsSpecificArguments(baseOs, workspace, unitySerial, runnerTemporaryPath, sshAgent): string {
4345
switch (baseOs) {
44-
case 'linux':
46+
case 'linux': {
47+
const githubHome = path.join(runnerTemporaryPath, '_github_home');
48+
if (!existsSync(githubHome)) mkdirSync(githubHome);
49+
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
50+
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
51+
4552
return `--env UNITY_SERIAL \
4653
--env GITHUB_WORKSPACE=/github/workspace \
4754
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
48-
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
49-
--volume "${runnerTemporaryPath}/_github_home":"/root" \
50-
--volume "${runnerTemporaryPath}/_github_workflow":"/github/workflow" \
51-
--volume "${workspace}":"/github/workspace" \
55+
--volume "/var/run/docker.sock":"/var/run/docker.sock:z" \
56+
--volume "${githubHome}":"/root:z" \
57+
--volume "${githubWorkflow}":"/github/workflow:z" \
58+
--volume "${workspace}":"/github/workspace:z" \
5259
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
5360
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
61+
}
5462
case 'win32':
5563
return `--env UNITY_SERIAL="${unitySerial}" \
5664
--env GITHUB_WORKSPACE=c:/github/workspace \

0 commit comments

Comments
 (0)