mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
fix: 解决创建运行环境报错的 BUG (#550)
This commit is contained in:
parent
18c5c99705
commit
0f1107314f
@ -248,7 +248,7 @@ func getContainerNames(install model.AppInstall) ([]string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
project, err := composeV2.GetComposeProject(install.Name, install.GetPath(), []byte(install.DockerCompose), []byte(envStr))
|
project, err := composeV2.GetComposeProject(install.Name, install.GetPath(), []byte(install.DockerCompose), []byte(envStr), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -400,7 +400,7 @@ func getServiceFromInstall(appInstall model.AppInstall) (service *composeV2.Comp
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
project, err = composeV2.GetComposeProject(appInstall.Name, appInstall.GetPath(), []byte(appInstall.DockerCompose), []byte(envStr))
|
project, err = composeV2.GetComposeProject(appInstall.Name, appInstall.GetPath(), []byte(appInstall.DockerCompose), []byte(envStr), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
composeService, err := getComposeService(create.Name, newNameDir, composeContent, envContent)
|
composeService, err := getComposeService(create.Name, newNameDir, composeContent, envContent, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
composeService, err := getComposeService(runtime.Name, runtimeDir, composeContent, envContent)
|
composeService, err := getComposeService(runtime.Name, runtimeDir, composeContent, envContent, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ func handleParams(image, runtimeType, runtimeDir string, params map[string]inter
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getComposeService(name, runtimeDir string, composeFile, env []byte) (*docker.ComposeService, error) {
|
func getComposeService(name, runtimeDir string, composeFile, env []byte, skipNormalization bool) (*docker.ComposeService, error) {
|
||||||
project, err := docker.GetComposeProject(name, runtimeDir, composeFile, env)
|
project, err := docker.GetComposeProject(name, runtimeDir, composeFile, env, skipNormalization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func (s *ComposeService) ComposeBuild() error {
|
|||||||
return s.Build(context.Background(), s.project, api.BuildOptions{})
|
return s.Build(context.Background(), s.project, api.BuildOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetComposeProject(projectName, workDir string, yml []byte, env []byte) (*types.Project, error) {
|
func GetComposeProject(projectName, workDir string, yml []byte, env []byte, skipNormalization bool) (*types.Project, error) {
|
||||||
var configFiles []types.ConfigFile
|
var configFiles []types.ConfigFile
|
||||||
configFiles = append(configFiles, types.ConfigFile{
|
configFiles = append(configFiles, types.ConfigFile{
|
||||||
Filename: "docker-compose.yml",
|
Filename: "docker-compose.yml",
|
||||||
@ -106,7 +106,7 @@ func GetComposeProject(projectName, workDir string, yml []byte, env []byte) (*ty
|
|||||||
project, err := loader.Load(details, func(options *loader.Options) {
|
project, err := loader.Load(details, func(options *loader.Options) {
|
||||||
options.SetProjectName(projectName, true)
|
options.SetProjectName(projectName, true)
|
||||||
options.ResolvePaths = true
|
options.ResolvePaths = true
|
||||||
options.SkipNormalization = true
|
options.SkipNormalization = skipNormalization
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user