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

feat: 应用商店支持多容器的本地应用 (#1108)

Refs https://github.com/1Panel-dev/1Panel/issues/635
This commit is contained in:
zhengkunwang223 2023-05-23 10:31:45 +08:00 committed by GitHub
parent f5cd45438b
commit c052887d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 19 deletions

View File

@ -286,32 +286,25 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
return
}
servicesMap := value.(map[string]interface{})
changeKeys := make(map[string]string, len(servicesMap))
index := 0
for k := range servicesMap {
serviceName := k + "-" + common.RandStr(4)
changeKeys[k] = serviceName
containerName := constant.ContainerPrefix + k + "-" + common.RandStr(4)
containerName := constant.ContainerPrefix + app.Key + "-" + common.RandStr(4)
if req.Advanced && req.ContainerName != "" {
containerName = req.ContainerName
}
req.Params[constant.ContainerName] = containerName
appInstall.ContainerName = containerName
index := 0
for k := range servicesMap {
appInstall.ServiceName = k
if index > 0 {
continue
}
req.Params[constant.ContainerName] = containerName
appInstall.ServiceName = serviceName
appInstall.ContainerName = containerName
index++
}
for k, v := range changeKeys {
servicesMap[v] = servicesMap[k]
delete(servicesMap, k)
}
if err = addDockerComposeCommonParam(composeMap, appInstall.ServiceName, req.AppContainerConfig, req.Params); err != nil {
return
}
var (
composeByte []byte
paramByte []byte

View File

@ -412,15 +412,15 @@ func handleMap(params map[string]interface{}, envParams map[string]string) {
func downloadApp(app model.App, appDetail model.AppDetail, appInstall *model.AppInstall) (err error) {
appResourceDir := path.Join(constant.AppResourceDir, app.Resource)
if !appDetail.Update {
appDownloadDir := path.Join(appResourceDir, app.Key)
appVersionDir := path.Join(appDownloadDir, appDetail.Version)
fileOp := files.NewFileOp()
if !appDetail.Update && fileOp.Stat(appVersionDir) {
return
}
fileOp := files.NewFileOp()
appDownloadDir := path.Join(appResourceDir, app.Key)
if !fileOp.Stat(appDownloadDir) {
_ = fileOp.CreateDir(appDownloadDir, 0755)
}
appVersionDir := path.Join(appDownloadDir, appDetail.Version)
if !fileOp.Stat(appVersionDir) {
_ = fileOp.CreateDir(appVersionDir, 0755)
}
@ -445,6 +445,8 @@ func downloadApp(app model.App, appDetail model.AppDetail, appInstall *model.App
return
}
_ = fileOp.DeleteFile(filePath)
appDetail.Update = false
_ = appDetailRepo.Update(context.Background(), appDetail)
return
}

View File

@ -69,6 +69,7 @@ declare module 'vue' {
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElText: typeof import('element-plus/es')['ElText']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElUpload: typeof import('element-plus/es')['ElUpload']
Err_domain: typeof import('./src/components/error-message/err_domain.vue')['default']