Skip to content

Commit a425320

Browse files
authored
add optionto set the docker 'device' command line argument (#1644)
1 parent ae80e11 commit a425320

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/argv.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ export class Argv {
215215
return this.map.get("privileged") ?? false;
216216
}
217217

218+
get device (): string | null {
219+
const device = this.map.get("device");
220+
if (!device) return null;
221+
return device;
222+
}
223+
218224
get ulimit (): string | null {
219225
const ulimit = this.map.get("ulimit");
220226
if (!ulimit) return null;

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ process.on("SIGUSR2", async () => await cleanupJobResources(jobs));
217217
description: "Set docker executor to privileged mode",
218218
requiresArg: false,
219219
})
220+
.option("device", {
221+
type: "string",
222+
description: "Set docker executor device option",
223+
requiresArg: false,
224+
})
220225
.option("ulimit", {
221226
type: "number",
222227
description: "Set docker executor ulimit",

src/job.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,10 @@ export class Job {
837837
dockerCmd += "--privileged ";
838838
}
839839

840+
if (this.argv.device) {
841+
dockerCmd += `--device=${this.argv.device} `;
842+
}
843+
840844
if (this.argv.ulimit !== null) {
841845
dockerCmd += `--ulimit nofile=${this.argv.ulimit} `;
842846
}
@@ -1414,6 +1418,10 @@ export class Job {
14141418
dockerCmd += "--privileged ";
14151419
}
14161420

1421+
if (this.argv.device) {
1422+
dockerCmd += `--device=${this.argv.device} `;
1423+
}
1424+
14171425
if (this.argv.ulimit !== null) {
14181426
dockerCmd += `--ulimit nofile=${this.argv.ulimit} `;
14191427
}

0 commit comments

Comments
 (0)