feat: 删除 app_container ,修改安装逻辑

This commit is contained in:
zhengkunwang223
2022-10-11 16:27:58 +08:00
committed by zhengkunwang223
parent 12617f95dd
commit c65afb7083
23 changed files with 377 additions and 313 deletions

View File

@@ -1,6 +1,10 @@
package compose
import "os/exec"
import (
"github.com/compose-spec/compose-go/loader"
"github.com/compose-spec/compose-go/types"
"os/exec"
)
func Up(filePath string) (string, error) {
cmd := exec.Command("docker-compose", "-f", filePath, "up", "-d")
@@ -25,3 +29,24 @@ func Rmf(filePath string) (string, error) {
stdout, err := cmd.CombinedOutput()
return string(stdout), err
}
func GetComposeProject(yml []byte, env map[string]string) (*types.Project, error) {
var configFiles []types.ConfigFile
configFiles = append(configFiles, types.ConfigFile{
Filename: "docker-compose.yml",
Content: yml},
)
details := types.ConfigDetails{
WorkingDir: "",
ConfigFiles: configFiles,
Environment: env,
}
project, err := loader.Load(details, func(options *loader.Options) {
})
if err != nil {
return nil, err
}
return project, nil
}