Skip to content

Commit f5a2667

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 7a0384c commit f5a2667

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/plugins/setup.ts

Lines changed: 17 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",
@@ -93,6 +94,14 @@ export default createPlugin(
9394
}
9495
}
9596

97+
let imagePulled = false;
98+
const pullImageProcess = updateDockerImage(
99+
outputChannel,
100+
cancellationToken,
101+
).then(() => {
102+
imagePulled = true;
103+
});
104+
96105
/////////////////////////////////////////////////////////////////////
97106
progress.report({
98107
message: "Verifying authentication...",
@@ -227,6 +236,14 @@ export default createPlugin(
227236
});
228237
await minDelay(Promise.resolve());
229238

239+
if (!imagePulled) {
240+
progress.report({
241+
message:
242+
"Waiting for the LocalStack docker image to finish downloading...",
243+
});
244+
await minDelay(pullImageProcess);
245+
}
246+
230247
/////////////////////////////////////////////////////////////////////
231248
if (localStackStatusTracker.status() === "running") {
232249
window

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)