[FIX] fix check port from dockerfile bug

This commit is contained in:
goodrain 2018-03-07 15:11:20 +08:00
parent e4e1e63906
commit 1aa4f051df
6 changed files with 18 additions and 15 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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)}
}

View File

@ -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

View File

@ -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 {