fix: 解决安装应用时候,原始 docker-compose.yml 的 deploy 字段下内容会被自动覆写的问题 (#4512)

Refs https://github.com/1Panel-dev/1Panel/issues/4340
This commit is contained in:
zhengkunwang 2024-04-15 11:54:09 +08:00 committed by GitHub
parent 43a6b4b735
commit c77742e72e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1229,16 +1229,18 @@ func addDockerComposeCommonParam(composeMap map[string]interface{}, serviceName
serviceValue := service.(map[string]interface{})
deploy := map[string]interface{}{}
if de, ok := serviceValue["deploy"]; ok {
deploy = de.(map[string]interface{})
}
deploy["resources"] = map[string]interface{}{
"limits": map[string]interface{}{
"cpus": "${CPUS}",
"memory": "${MEMORY_LIMIT}",
},
resource := map[string]interface{}{}
if res, ok := deploy["resources"]; ok {
resource = res.(map[string]interface{})
}
resource["limits"] = map[string]interface{}{
"cpus": "${CPUS}",
"memory": "${MEMORY_LIMIT}",
}
deploy["resources"] = resource
serviceValue["deploy"] = deploy
ports, ok := serviceValue["ports"].([]interface{})