diff --git a/pkg/builder/exector/build_from_image_run.go b/pkg/builder/exector/build_from_image_run.go index ae578b7f4..87bfc944b 100644 --- a/pkg/builder/exector/build_from_image_run.go +++ b/pkg/builder/exector/build_from_image_run.go @@ -150,7 +150,7 @@ func (i *ImageBuildItem) StorageLocalImageURL(imageURL string) error { //StorageVersionInfo 存储version信息 func (i *ImageBuildItem) StorageVersionInfo(imageURL string) error { - version, err := db.GetManager().VersionInfoDao().GetVersionByEventID(i.EventID) + version, err := db.GetManager().VersionInfoDao().GetVersionByDeployVersion(i.DeployVersion, i.ServiceID) if err != nil { return err } diff --git a/pkg/builder/exector/build_from_market_slug.go b/pkg/builder/exector/build_from_market_slug.go index e31b8a6aa..feec398b4 100644 --- a/pkg/builder/exector/build_from_market_slug.go +++ b/pkg/builder/exector/build_from_market_slug.go @@ -130,7 +130,7 @@ func (i *MarketSlugItem) CreateUpgradeTaskBody() *model.RollingUpgradeTaskBody { //UpdateVersionInfo 更新任务执行结果 func (i *MarketSlugItem) UpdateVersionInfo(vi *dbmodel.VersionInfo) error { - version, err := db.GetManager().VersionInfoDao().GetVersionByEventID(i.EventID) + version, err := db.GetManager().VersionInfoDao().GetVersionByDeployVersion(i.DeployVersion, i.ServiceID) if err != nil { return err } diff --git a/pkg/builder/exector/build_from_sourcecode_run.go b/pkg/builder/exector/build_from_sourcecode_run.go index 0023b9be0..029139078 100644 --- a/pkg/builder/exector/build_from_sourcecode_run.go +++ b/pkg/builder/exector/build_from_sourcecode_run.go @@ -385,7 +385,7 @@ func (i *SourceCodeBuildItem) CreateUpgradeTaskBody() *model.RollingUpgradeTaskB //UpdateVersionInfo 更新任务执行结果 func (i *SourceCodeBuildItem) UpdateVersionInfo(vi *dbmodel.VersionInfo) error { - version, err := db.GetManager().VersionInfoDao().GetVersionByEventID(i.EventID) + version, err := db.GetManager().VersionInfoDao().GetVersionByDeployVersion(i.DeployVersion, i.ServiceID) if err != nil { return err } diff --git a/pkg/builder/parser/source_code.go b/pkg/builder/parser/source_code.go index df94d6c10..e3c7e3f0c 100644 --- a/pkg/builder/parser/source_code.go +++ b/pkg/builder/parser/source_code.go @@ -353,8 +353,8 @@ func (d *SourceCodeParse) parseDockerfileInfo(dockerfile string) bool { d.envs[cm.Value[0]] = &Env{Name: cm.Value[0], Value: cm.Value[1]} } case "expose": - if len(cm.Value) == 1 { - port, _ := strconv.Atoi(cm.Value[0]) + for _, v := range cm.Value { + port, _ := strconv.Atoi(v) if port != 0 { d.ports[port] = &Port{ContainerPort: port, Protocol: GetPortProtocol(port)} } diff --git a/pkg/builder/sources/image.go b/pkg/builder/sources/image.go index 805f748a8..4cf7793f2 100644 --- a/pkg/builder/sources/image.go +++ b/pkg/builder/sources/image.go @@ -146,7 +146,7 @@ func ImagePush(dockerCli *client.Client, image string, opts types.ImagePushOptio defer cancel() readcloser, err := dockerCli.ImagePush(ctx, image, opts) if err != nil { - if strings.HasSuffix(err.Error(), "does not exist") { + if strings.Contains(err.Error(), "does not exist") { if logger != nil { logger.Error(fmt.Sprintf("镜像:%s不存在,不能推送", image), map[string]string{"step": "pushimage"}) } @@ -210,16 +210,19 @@ func ImageBuild(dockerCli *client.Client, contextDir string, options types.Image if err != nil { return err } - r := bufio.NewReader(rc.Body) - for { - if line, _, err := r.ReadLine(); err == nil { - if logger != nil { - logger.Debug(string(line), map[string]string{"step": "build-progress"}) + if rc.Body != nil { + defer rc.Body.Close() + r := bufio.NewReader(rc.Body) + for { + if line, _, err := r.ReadLine(); err == nil { + if logger != nil { + logger.Debug(string(line), map[string]string{"step": "build-progress"}) + } else { + fmt.Println(string(line)) + } } else { - fmt.Println(string(line)) + break } - } else { - break } } return nil diff --git a/pkg/builder/sources/image_test.go b/pkg/builder/sources/image_test.go index fc12166ea..f93d0d89c 100644 --- a/pkg/builder/sources/image_test.go +++ b/pkg/builder/sources/image_test.go @@ -42,7 +42,7 @@ func TestImageName(t *testing.T) { func TestBuildImage(t *testing.T) { dc, _ := client.NewEnvClient() buildOptions := types.ImageBuildOptions{ - Tags: []string{"build:test"}, + Tags: []string{"goodrain.me/gr1e1a6c_goodrain-apps_gost:20180307135753"}, Remove: true, } if err := ImageBuild(dc, "/tmp/gost", buildOptions, nil, 5); err != nil {