diff --git a/hyperdrive-cli/client/service.go b/hyperdrive-cli/client/service.go index a10c981c..5b3fa8ee 100644 --- a/hyperdrive-cli/client/service.go +++ b/hyperdrive-cli/client/service.go @@ -192,6 +192,15 @@ func (c *HyperdriveClient) StopService(composeFiles []string) error { return printOutput(cmd) } +// Pull new container images +func (c *HyperdriveClient) PullImages(composeFiles []string) error { + cmd, err := c.compose(composeFiles, "pull -q") + if err != nil { + return err + } + return printOutput(cmd) +} + // Stop the Hyperdrive service, shutting it down and removing the Docker artifacts func (c *HyperdriveClient) DownService(composeFiles []string, includeVolumes bool) error { args := "down" diff --git a/hyperdrive-cli/commands/service/config.go b/hyperdrive-cli/commands/service/config.go index 38468261..6ce1dcb6 100644 --- a/hyperdrive-cli/commands/service/config.go +++ b/hyperdrive-cli/commands/service/config.go @@ -135,6 +135,14 @@ func configureService(c *cli.Context) error { fmt.Fprintf(os.Stderr, "Warning: couldn't check running containers: %s\n", err.Error()) runningContainers = map[string]bool{} } + + // Let's reduce potential downtime by pulling the new containers before restarting + fmt.Println("Pulling potential new container images...") + err = hd.PullImages(getComposeFiles(c)) + if err != nil { + fmt.Fprintf(os.Stderr, "Warning: couldn't pul new images for updated containers: %s\n", err.Error()) + } + for _, container := range md.ContainersToRestart { fullName := fmt.Sprintf("%s_%s", prefix, container) if !runningContainers[fullName] {