Skip to content

Commit 8bfe604

Browse files
authored
modify the used image wait-for-it #1552 (#1632)
* add waitImage param * fix lint error
1 parent c2d81dd commit 8bfe604

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/argv.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ export class Argv {
322322
return this.map.get("defaultImage") ?? "docker.io/ruby:3.1";
323323
}
324324

325+
get waitImage (): string {
326+
return this.map.get("waitImage") ?? "docker.io/sumina46/wait-for-it:latest";
327+
}
328+
325329
get helperImage (): string {
326330
return this.map.get("helperImage") ?? "docker.io/firecow/gitlab-ci-local-util:latest";
327331
}

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ process.on("SIGUSR2", async () => await cleanupJobResources(jobs));
187187
description: "When using --shell-executor-no-image=false which image to be used for the container. Defaults to docker.io/ruby:3.1 if not set.",
188188
requiresArg: false,
189189
})
190+
.option("wait-image", {
191+
type: "string",
192+
description: "Which image to be used for the wait container. Defaults to docker.io/sumina46/wait-for-it:latest if not set.",
193+
requiresArg: false,
194+
})
190195
.option("helper-image", {
191196
type: "string",
192197
description: "When using --shell-executor-no-image=false which image to be used for the utils container. Defaults to docker.io/firecow/gitlab-ci-local-util:latest if not set.",

src/job.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,7 @@ export class Job {
14871487
private async serviceHealthCheck (writeStreams: WriteStreams, service: Service, serviceIndex: number, serviceContainerLogFile: string) {
14881488
const serviceAlias = service.alias;
14891489
const serviceName = service.name;
1490+
const waitImageName = this.argv.waitImage;
14901491

14911492
const {stdout} = await Utils.spawn([this.argv.containerExecutable, "image", "inspect", serviceName]);
14921493
const imageInspect = JSON.parse(stdout);
@@ -1511,7 +1512,7 @@ export class Job {
15111512
if (!port.endsWith("/tcp")) return;
15121513
const portNum = parseInt(port.replace("/tcp", ""));
15131514
const containerName = `gcl-wait-for-it-${this.jobId}-${serviceIndex}-${portNum}`;
1514-
const spawnCmd = [this.argv.containerExecutable, "run", "--rm", `--name=${containerName}`, "--network", `${this._serviceNetworkId}`, "docker.io/sumina46/wait-for-it", `${uniqueAlias}:${portNum}`, "-t", "30"];
1515+
const spawnCmd = [this.argv.containerExecutable, "run", "--rm", `--name=${containerName}`, "--network", `${this._serviceNetworkId}`, `${waitImageName}`, `${uniqueAlias}:${portNum}`, "-t", "30"];
15151516
this._containersToClean.push(containerName);
15161517
return Utils.spawn(spawnCmd);
15171518
}));

0 commit comments

Comments
 (0)