1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

fix: 解决 compose 创建错误未存库的问题

This commit is contained in:
ssongliu 2023-03-17 19:11:03 +08:00 committed by f2c-ci-robot[bot]
parent 84fcd31704
commit 927def4472
2 changed files with 10 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"path"
"sort"
"strings"
"time"
@ -152,11 +153,16 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) error {
req.Path = path
}
global.LOG.Infof("docker-compose.yml %s create successful, start to docker-compose up", req.Name)
if stdout, err := compose.Up(req.Path); err != nil {
return errors.New(string(stdout))
}
if req.From == "path" {
req.Name = path.Base(strings.ReplaceAll(req.Path, "/docker-compose.yml", ""))
}
if stdout, err := compose.Up(req.Path); err != nil {
_, _ = compose.Down(req.Path)
return errors.New(stdout)
}
_ = composeRepo.CreateRecord(&model.Compose{Name: req.Name})
return nil
}

View File

@ -7,7 +7,7 @@ import (
)
func Up(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s up -d", filePath)
stdout, err := cmd.Execf("docker-compose -f %s up -d --quiet-pull", filePath)
return stdout, err
}