Skip to content

Commit

Permalink
docker: return docker sock path on install
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Feb 29, 2024
1 parent 7ed7bac commit cae64f3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/docker/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class Install {
return tooldir;
}

public async install(): Promise<void> {
public async install(): Promise<string> {
if (!this.toolDir) {
throw new Error('toolDir must be set. Run download first.');
}
Expand All @@ -120,24 +120,21 @@ export class Install {
}
switch (os.platform()) {
case 'darwin': {
await this.installDarwin();
break;
return await this.installDarwin();
}
case 'linux': {
await this.installLinux();
break;
return await this.installLinux();
}
case 'win32': {
await this.installWindows();
break;
return await this.installWindows();
}
default: {
throw new Error(`Unsupported platform: ${os.platform()}`);
}
}
}

private async installDarwin(): Promise<void> {
private async installDarwin(): Promise<string> {
const limaDir = path.join(os.homedir(), '.lima', this.limaInstanceName);
await io.mkdirP(limaDir);
const dockerHost = `unix://${limaDir}/docker.sock`;
Expand Down Expand Up @@ -225,9 +222,11 @@ export class Install {
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
await Exec.exec('docker', ['context', 'use', this.contextName]);
});

return dockerHost;
}

private async installLinux(): Promise<void> {
private async installLinux(): Promise<string> {
const dockerHost = `unix://${path.join(this.runDir, 'docker.sock')}`;
await io.mkdirP(this.runDir);

Expand Down Expand Up @@ -306,9 +305,11 @@ EOF`,
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
await Exec.exec('docker', ['context', 'use', this.contextName]);
});

return dockerHost;
}

private async installWindows(): Promise<void> {
private async installWindows(): Promise<string> {
const dockerHost = 'npipe:////./pipe/setup_docker_action';

let daemonConfig = undefined;
Expand Down Expand Up @@ -347,6 +348,8 @@ EOF`,
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
await Exec.exec('docker', ['context', 'use', this.contextName]);
});

return dockerHost;
}

public async tearDown(): Promise<void> {
Expand Down

0 comments on commit cae64f3

Please sign in to comment.