Skip to content

Commit

Permalink
feat: only pull setup image if it doesn't exist locally
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnr committed Jan 12, 2022
1 parent 0260678 commit 824c209
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,17 @@ func setupVm(
) error {
imageName := fmt.Sprintf("%s:%s", version.SetupImage, version.Version)

pullStream, err := dockerCli.ImagePull(ctx, imageName, types.ImagePullOptions{})
_, _, err := dockerCli.ImageInspectWithRaw(ctx, imageName)
if err != nil {
fmt.Errorf("Failed to create container")
return err
}
fmt.Printf("Image doesn't exist locally. Pulling...\n")

pullStream, err := dockerCli.ImagePull(ctx, imageName, types.ImagePullOptions{})
if err != nil {
return fmt.Errorf("failed to pull setup image: %w", err)
}

io.Copy(os.Stdout, pullStream)
io.Copy(os.Stdout, pullStream)
}

resp, err := dockerCli.ContainerCreate(ctx, &container.Config{
Image: imageName,
Expand Down

0 comments on commit 824c209

Please sign in to comment.