Skip to content

Commit 329bad9

Browse files
committed
Start pulling docker image after CLI install
If we start pulling docker image as a first thing in the setup process then `docker pull` consumes all the bandwidth and makes CLI download an order of magnitude longer. If we start pulling image right after the install step it still takes advantage of time that user spends in the rest of setup steps. Options considered: start `docker pull` right after CLI is downloaded. This way we could take advantage of time spent in another modal - global/local selection. Trade off is that passing image pull progress from/to runInstallProcess is adding complexity that is not justified with 2-3 seconds saved.
1 parent 6c4a5b1 commit 329bad9

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/plugins/setup.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
activateLicenseUntilValid,
1515
} from "../utils/license.ts";
1616
import { minDelay } from "../utils/promises.ts";
17+
import { updateDockerImage } from "../utils/setup.ts";
1718

1819
export default createPlugin(
1920
"setup",
@@ -87,6 +88,14 @@ export default createPlugin(
8788
}
8889
}
8990

91+
let imagePulled = false;
92+
const pullImageProcess = updateDockerImage(
93+
outputChannel,
94+
cancellationToken,
95+
).then(() => {
96+
imagePulled = true;
97+
});
98+
9099
/////////////////////////////////////////////////////////////////////
91100
progress.report({
92101
message: "Verifying authentication...",
@@ -218,6 +227,15 @@ export default createPlugin(
218227
});
219228
await minDelay(Promise.resolve());
220229

230+
/////////////////////////////////////////////////////////////////////
231+
if (!imagePulled) {
232+
progress.report({
233+
message:
234+
"Waiting for the LocalStack docker image to finish downloading...",
235+
});
236+
await minDelay(pullImageProcess);
237+
}
238+
221239
/////////////////////////////////////////////////////////////////////
222240
window
223241
.showInformationMessage("LocalStack is ready to start", {

src/utils/setup.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { LogOutputChannel } from "vscode";
1+
import type { CancellationToken, LogOutputChannel } from "vscode";
22
import * as z from "zod/v4-mini";
33

44
import { checkIsAuthenticated } from "./authenticate.ts";
@@ -29,10 +29,11 @@ const LOCALSTACK_DOCKER_IMAGE = "localstack/localstack-pro";
2929

3030
export async function updateDockerImage(
3131
outputChannel: LogOutputChannel,
32+
cancellationToken: CancellationToken,
3233
): Promise<void> {
3334
const imageVersion = await getDockerImageSemverVersion(outputChannel);
3435
if (!imageVersion) {
35-
await pullDockerImage(outputChannel);
36+
await pullDockerImage(outputChannel, cancellationToken);
3637
}
3738
}
3839

@@ -79,11 +80,15 @@ async function getDockerImageSemverVersion(
7980
return imageVersion;
8081
}
8182

82-
async function pullDockerImage(outputChannel: LogOutputChannel): Promise<void> {
83+
async function pullDockerImage(
84+
outputChannel: LogOutputChannel,
85+
cancellationToken: CancellationToken,
86+
): Promise<void> {
8387
try {
8488
await spawn("docker", ["pull", LOCALSTACK_DOCKER_IMAGE], {
8589
outputChannel,
8690
outputLabel: "docker.pull",
91+
cancellationToken: cancellationToken,
8792
});
8893
} catch (error) {
8994
outputChannel.error("Could not pull LocalStack docker image");

0 commit comments

Comments
 (0)