Skip to content

Commit 7018b1d

Browse files
feat(runtime): Add .NET runtime
1 parent c3565f7 commit 7018b1d

File tree

17 files changed

+746
-19
lines changed

17 files changed

+746
-19
lines changed

backend/app/service/app_utils.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1107,11 +1107,7 @@ func handleLocalAppDetail(versionDir string, appDetail *model.AppDetail) error {
11071107
return buserr.WithMap(constant.ErrFileParseApp, map[string]interface{}{"name": "data.yml", "err": err.Error()}, err)
11081108
}
11091109

1110-
additionalProperties, ok := dataMap["additionalProperties"].(map[string]interface{})
1111-
if !ok {
1112-
return buserr.WithName(constant.ErrAppParamKey, "additionalProperties")
1113-
}
1114-
1110+
additionalProperties, _ := dataMap["additionalProperties"].(map[string]interface{})
11151111
formFieldsInterface, ok := additionalProperties["formFields"]
11161112
if ok {
11171113
formFields, ok := formFieldsInterface.([]interface{})

backend/app/service/runtime.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e
8383
if exist != nil {
8484
return nil, buserr.New(constant.ErrImageExist)
8585
}
86-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
86+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
8787
if !fileOp.Stat(create.CodeDir) {
8888
return nil, buserr.New(constant.ErrPathNotFound)
8989
}
@@ -113,7 +113,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e
113113
}
114114

115115
appVersionDir := filepath.Join(app.GetAppResourcePath(), appDetail.Version)
116-
if !fileOp.Stat(appVersionDir) || appDetail.Update {
116+
if !fileOp.Stat(appVersionDir) {
117117
if err = downloadApp(app, appDetail, nil); err != nil {
118118
return nil, err
119119
}
@@ -133,7 +133,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e
133133
if err = handlePHP(create, runtime, fileOp, appVersionDir); err != nil {
134134
return nil, err
135135
}
136-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
136+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
137137
runtime.Port = create.Port
138138
if err = handleNodeAndJava(create, runtime, fileOp, appVersionDir); err != nil {
139139
return nil, err
@@ -217,7 +217,7 @@ func (r *RuntimeService) Delete(runtimeDelete request.RuntimeDelete) error {
217217
global.LOG.Errorf("delete image id [%s] error %v", imageID, err)
218218
}
219219
}
220-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
220+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
221221
if out, err := compose.Down(runtime.GetComposePath()); err != nil && !runtimeDelete.ForceDelete {
222222
if out != "" {
223223
return errors.New(out)
@@ -300,7 +300,7 @@ func (r *RuntimeService) Get(id uint) (*response.RuntimeDTO, error) {
300300
}
301301
}
302302
res.AppParams = appParams
303-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
303+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
304304
res.Params = make(map[string]interface{})
305305
envs, err := gotenv.Unmarshal(runtime.Env)
306306
if err != nil {
@@ -361,7 +361,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
361361
if exist != nil {
362362
return buserr.New(constant.ErrImageExist)
363363
}
364-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
364+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
365365
if runtime.Port != req.Port {
366366
if err = checkPortExist(req.Port); err != nil {
367367
return err
@@ -441,7 +441,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
441441
return err
442442
}
443443
go buildRuntime(runtime, imageID, req.Rebuild)
444-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
444+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
445445
runtime.Version = req.Version
446446
runtime.CodeDir = req.CodeDir
447447
runtime.Port = req.Port
@@ -613,7 +613,7 @@ func (r *RuntimeService) SyncRuntimeStatus() error {
613613
return err
614614
}
615615
for _, runtime := range runtimes {
616-
if runtime.Type == constant.RuntimeNode || runtime.Type == constant.RuntimeJava || runtime.Type == constant.RuntimeGo {
616+
if runtime.Type != constant.RuntimePHP {
617617
_ = SyncRuntimeContainerStatus(&runtime)
618618
}
619619
}

backend/app/service/runtime_utils.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ func handleParams(create request.RuntimeCreate, projectDir string) (composeConte
354354
if err != nil {
355355
return
356356
}
357+
case constant.RuntimeDoNet:
358+
create.Params["CODE_DIR"] = create.CodeDir
359+
create.Params["DONET_VERSION"] = create.Version
360+
create.Params["PANEL_APP_PORT_HTTP"] = create.Port
361+
composeContent, err = handleCompose(env, composeContent, create, projectDir)
362+
if err != nil {
363+
return
364+
}
357365
}
358366

359367
newMap := make(map[string]string)
@@ -400,7 +408,7 @@ func handleCompose(env gotenv.Env, composeContent []byte, create request.Runtime
400408
ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${JAVA_APP_PORT}")
401409
case constant.RuntimeGo:
402410
ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${GO_APP_PORT}")
403-
case constant.RuntimePython:
411+
case constant.RuntimePython, constant.RuntimeDoNet:
404412
ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${APP_PORT}")
405413
}
406414

backend/app/service/website.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
352352
}
353353
website.Proxy = proxy
354354
}
355-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
355+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
356356
website.Proxy = fmt.Sprintf("127.0.0.1:%d", runtime.Port)
357357
}
358358
}

backend/app/service/website_utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
277277
server.UpdateRoot(rootIndex)
278278
server.UpdatePHPProxy([]string{website.Proxy}, "")
279279
}
280-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
280+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
281281
proxy := fmt.Sprintf("http://127.0.0.1:%d", runtime.Port)
282282
server.UpdateRootProxy([]string{proxy})
283283
}

backend/constant/common.go

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ var WebUrlMap = map[string]struct{}{
9999
"/websites/runtimes/net": {},
100100
"/websites/runtimes/go": {},
101101
"/websites/runtimes/python": {},
102+
"/websites/runtimes/donet": {},
102103

103104
"/login": {},
104105

backend/constant/runtime.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const (
1919
RuntimeJava = "java"
2020
RuntimeGo = "go"
2121
RuntimePython = "python"
22+
RuntimeDoNet = "donet"
2223

2324
RuntimeProxyUnix = "unix"
2425
RuntimeProxyTcp = "tcp"

frontend/src/lang/modules/en.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2428,6 +2428,7 @@ const message = {
24282428
goDirHelper: 'The directory must contain go files or binary files, subdirectories are also acceptable',
24292429
pythonHelper:
24302430
'Please fill in the complete startup command, for example: pip install -r requirements.txt && python manage.py runserver 0.0.0.0:5000',
2431+
donetHelper: 'Please fill in the complete startup comman, for example: dotnet MyWebApp.dll',
24312432
},
24322433
process: {
24332434
pid: 'Process ID',

frontend/src/lang/modules/tw.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2247,6 +2247,7 @@ const message = {
22472247
goDirHelper: '目錄中要包含 go 文件或者二進制文件,子目錄中包含也可',
22482248
pythonHelper:
22492249
'請填入完整啟動指令,例如:pip install -r requirements.txt && python manage.py runserver 0.0.0.0:5000',
2250+
donetHelper: '請填入完整啟動指令,例如 dotnet MyWebApp.dll',
22502251
},
22512252
process: {
22522253
pid: '進程ID',

frontend/src/lang/modules/zh.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2249,6 +2249,7 @@ const message = {
22492249
goDirHelper: '目录中要包含 go 文件或者二进制文件,子目录中包含也可',
22502250
pythonHelper:
22512251
'请填写完整启动命令,例如:pip install -r requirements.txt && python manage.py runserver 0.0.0.0:5000',
2252+
donetHelper: '请填写完整启动命令,例如 dotnet MyWebApp.dll',
22522253
},
22532254
process: {
22542255
pid: '进程ID',

frontend/src/routers/modules/website.ts

+10
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ const webSiteRouter = {
8888
requiresAuth: false,
8989
},
9090
},
91+
{
92+
path: '/websites/runtimes/donet',
93+
name: 'doNet',
94+
hidden: true,
95+
component: () => import('@/views/website/runtime/donet/index.vue'),
96+
meta: {
97+
activeMenu: '/websites/runtimes/php',
98+
requiresAuth: false,
99+
},
100+
},
91101
],
92102
};
93103

frontend/src/views/app-store/apps/index.vue

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ const openInstall = (app: App.App) => {
237237
case 'java':
238238
case 'go':
239239
case 'python':
240+
case 'donet':
240241
router.push({ path: '/websites/runtimes/' + app.type });
241242
break;
242243
default:

frontend/src/views/app-store/detail/index.vue

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const openInstall = () => {
146146
case 'java':
147147
case 'go':
148148
case 'python':
149+
case 'donet':
149150
router.push({ path: '/websites/runtimes/' + app.value.type });
150151
break;
151152
default:

frontend/src/views/home/app/index.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ const acceptParams = (): void => {
6767
const goInstall = (key: string, type: string) => {
6868
switch (type) {
6969
case 'php':
70-
router.push({ path: '/websites/runtimes/php' });
71-
break;
7270
case 'node':
73-
router.push({ path: '/websites/runtimes/node' });
71+
case 'java':
72+
case 'go':
73+
case 'python':
74+
case 'donet':
75+
router.push({ path: '/websites/runtimes/' + type });
7476
break;
7577
default:
7678
router.push({ name: 'AppAll', query: { install: key } });

0 commit comments

Comments
 (0)