From cccbaafd1ba92e6c7a4672f0c0e6d71c6cad719a Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:55:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=20(#6983?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_utils.go | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index b1d7c1b2a..c0ff8ad33 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -924,18 +924,34 @@ func upApp(appInstall *model.AppInstall, pullImages bool) { errMsg string ) if pullImages && appInstall.App.Type != "php" { - out, err = compose.Pull(appInstall.GetComposePath()) + projectName := strings.ToLower(appInstall.Name) + envByte, err := files.NewFileOp().GetContent(appInstall.GetEnvPath()) if err != nil { - if out != "" { - if strings.Contains(out, "no such host") { - errMsg = i18n.GetMsgByKey("ErrNoSuchHost") + ":" - } - if strings.Contains(out, "timeout") { - errMsg = i18n.GetMsgByKey("ErrImagePullTimeOut") + ":" + return err + } + images, err := composeV2.GetDockerComposeImages(projectName, envByte, []byte(appInstall.DockerCompose)) + if err != nil { + return err + } + for _, image := range images { + if out, err = cmd.ExecWithTimeOut("docker pull "+image, 60*time.Minute); err != nil { + if out != "" { + if strings.Contains(out, "no such host") { + errMsg = i18n.GetMsgByKey("ErrNoSuchHost") + ":" + } + if strings.Contains(out, "timeout") { + errMsg = i18n.GetMsgByKey("ErrImagePullTimeOut") + ":" + } + } else { + if err.Error() == buserr.New(constant.ErrCmdTimeout).Error() { + errMsg = i18n.GetMsgByKey("ErrImagePullTimeOut") + } else { + errMsg = i18n.GetMsgWithMap("ErrImagePull", map[string]interface{}{"err": err.Error()}) + } } appInstall.Message = errMsg + out + return err } - return err } }