Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtime): Add .NET runtime #7155

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions backend/app/service/app_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,11 +1107,7 @@ func handleLocalAppDetail(versionDir string, appDetail *model.AppDetail) error {
return buserr.WithMap(constant.ErrFileParseApp, map[string]interface{}{"name": "data.yml", "err": err.Error()}, err)
}

additionalProperties, ok := dataMap["additionalProperties"].(map[string]interface{})
if !ok {
return buserr.WithName(constant.ErrAppParamKey, "additionalProperties")
}

additionalProperties, _ := dataMap["additionalProperties"].(map[string]interface{})
formFieldsInterface, ok := additionalProperties["formFields"]
if ok {
formFields, ok := formFieldsInterface.([]interface{})
Expand Down
16 changes: 8 additions & 8 deletions backend/app/service/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e
if exist != nil {
return nil, buserr.New(constant.ErrImageExist)
}
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
if !fileOp.Stat(create.CodeDir) {
return nil, buserr.New(constant.ErrPathNotFound)
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e
}

appVersionDir := filepath.Join(app.GetAppResourcePath(), appDetail.Version)
if !fileOp.Stat(appVersionDir) || appDetail.Update {
if !fileOp.Stat(appVersionDir) {
if err = downloadApp(app, appDetail, nil); err != nil {
return nil, err
}
Expand All @@ -133,7 +133,7 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e
if err = handlePHP(create, runtime, fileOp, appVersionDir); err != nil {
return nil, err
}
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
runtime.Port = create.Port
if err = handleNodeAndJava(create, runtime, fileOp, appVersionDir); err != nil {
return nil, err
Expand Down Expand Up @@ -217,7 +217,7 @@ func (r *RuntimeService) Delete(runtimeDelete request.RuntimeDelete) error {
global.LOG.Errorf("delete image id [%s] error %v", imageID, err)
}
}
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
if out, err := compose.Down(runtime.GetComposePath()); err != nil && !runtimeDelete.ForceDelete {
if out != "" {
return errors.New(out)
Expand Down Expand Up @@ -300,7 +300,7 @@ func (r *RuntimeService) Get(id uint) (*response.RuntimeDTO, error) {
}
}
res.AppParams = appParams
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
res.Params = make(map[string]interface{})
envs, err := gotenv.Unmarshal(runtime.Env)
if err != nil {
Expand Down Expand Up @@ -361,7 +361,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
if exist != nil {
return buserr.New(constant.ErrImageExist)
}
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
if runtime.Port != req.Port {
if err = checkPortExist(req.Port); err != nil {
return err
Expand Down Expand Up @@ -441,7 +441,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
return err
}
go buildRuntime(runtime, imageID, req.Rebuild)
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
runtime.Version = req.Version
runtime.CodeDir = req.CodeDir
runtime.Port = req.Port
Expand Down Expand Up @@ -613,7 +613,7 @@ func (r *RuntimeService) SyncRuntimeStatus() error {
return err
}
for _, runtime := range runtimes {
if runtime.Type == constant.RuntimeNode || runtime.Type == constant.RuntimeJava || runtime.Type == constant.RuntimeGo {
if runtime.Type != constant.RuntimePHP {
_ = SyncRuntimeContainerStatus(&runtime)
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an overview of the code's differences.

The most significant difference between this and its previous version may be:

  • The addition and removal of some lines, which might contain bugs or improvements if it was applied after September 1st, 2021.
  • The inclusion of new line numbers indicating where to look for changes based on when it was last tested or updated with new knowledge about current versions and standards. For instance, we've added - case constant.RuntimeDO_NET at page 613 onwards due to recent discoveries of newer DO.NET runtime features.

To ensure high-quality coding and avoid regression issues:

  • Use commit messages to clearly identify changes and their effects.
  • Implement regular testing that mirrors what was done originally but with more rigorous scrutiny against today’s standards.
  • If using a Git-based development environment like GitHub Actions/GitLab CI/Delilge, use tags or labels in such repositories. This aids better tracking down history of revisions related to specific conditions encountered over time.

If you require further details along these lines I am available to assist.

Expand Down
10 changes: 9 additions & 1 deletion backend/app/service/runtime_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ func handleParams(create request.RuntimeCreate, projectDir string) (composeConte
if err != nil {
return
}
case constant.RuntimeDoNet:
create.Params["CODE_DIR"] = create.CodeDir
create.Params["DONET_VERSION"] = create.Version
create.Params["PANEL_APP_PORT_HTTP"] = create.Port
composeContent, err = handleCompose(env, composeContent, create, projectDir)
if err != nil {
return
}
}

newMap := make(map[string]string)
Expand Down Expand Up @@ -400,7 +408,7 @@ func handleCompose(env gotenv.Env, composeContent []byte, create request.Runtime
ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${JAVA_APP_PORT}")
case constant.RuntimeGo:
ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${GO_APP_PORT}")
case constant.RuntimePython:
case constant.RuntimePython, constant.RuntimeDoNet:
ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${APP_PORT}")
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes needed! The code does not contain any irregularities, potential issues, or optimizations that can be suggested at this time. If there were to be any updates in the future, these would likely need to involve specific features or improvements based on new requirements or technology advancements.

Keep in mind though, the previous knowledge cutoff is from 2021-09-01, so please update your checks as necessary when reviewing newer versions of code.

Expand Down
2 changes: 1 addition & 1 deletion backend/app/service/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
}
website.Proxy = proxy
}
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
website.Proxy = fmt.Sprintf("127.0.0.1:%d", runtime.Port)
}
}
Expand Down
2 changes: 1 addition & 1 deletion backend/app/service/website_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
server.UpdateRoot(rootIndex)
server.UpdatePHPProxy([]string{website.Proxy}, "")
}
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython:
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDoNet:
proxy := fmt.Sprintf("http://127.0.0.1:%d", runtime.Port)
server.UpdateRootProxy([]string{proxy})
}
Expand Down
1 change: 1 addition & 0 deletions backend/constant/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ var WebUrlMap = map[string]struct{}{
"/websites/runtimes/net": {},
"/websites/runtimes/go": {},
"/websites/runtimes/python": {},
"/websites/runtimes/donet": {},

"/login": {},

Expand Down
1 change: 1 addition & 0 deletions backend/constant/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
RuntimeJava = "java"
RuntimeGo = "go"
RuntimePython = "python"
RuntimeDoNet = "donet"

RuntimeProxyUnix = "unix"
RuntimeProxyTcp = "tcp"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2428,6 +2428,7 @@ const message = {
goDirHelper: 'The directory must contain go files or binary files, subdirectories are also acceptable',
pythonHelper:
'Please fill in the complete startup command, for example: pip install -r requirements.txt && python manage.py runserver 0.0.0.0:5000',
donetHelper: 'Please fill in the complete startup comman, for example: dotnet MyWebApp.dll',
},
process: {
pid: 'Process ID',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2247,6 +2247,7 @@ const message = {
goDirHelper: '目錄中要包含 go 文件或者二進制文件,子目錄中包含也可',
pythonHelper:
'請填入完整啟動指令,例如:pip install -r requirements.txt && python manage.py runserver 0.0.0.0:5000',
donetHelper: '請填入完整啟動指令,例如 dotnet MyWebApp.dll',
},
process: {
pid: '進程ID',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,7 @@ const message = {
goDirHelper: '目录中要包含 go 文件或者二进制文件,子目录中包含也可',
pythonHelper:
'请填写完整启动命令,例如:pip install -r requirements.txt && python manage.py runserver 0.0.0.0:5000',
donetHelper: '请填写完整启动命令,例如 dotnet MyWebApp.dll',
},
process: {
pid: '进程ID',
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/routers/modules/website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ const webSiteRouter = {
requiresAuth: false,
},
},
{
path: '/websites/runtimes/donet',
name: 'doNet',
hidden: true,
component: () => import('@/views/website/runtime/donet/index.vue'),
meta: {
activeMenu: '/websites/runtimes/php',
requiresAuth: false,
},
},
],
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't appear to be any known issues with the given JavaScript code provided here. The code seems to define an array containing URLs (webSiteRouter), their corresponding components using Vue.js, name, and other properties, where necessary (as per documentation). No potential issues such as syntax errors or incorrect structure have been identified.

For optimization purposes:

If this component is used frequently across multiple routes (e.g., home page, profile, etc.) on the same page or similar pages, one approach could enhance readability and maintainability would use ES module system like CommonJS or AMD instead of importing all functions directly within a script tag at the topmost level.

But if you're looking for a suggestion related to "knowledge cutoff" from 2021-09-01, I'd recommend checking that specific point out because details about programming standards vary significantly over time; it's also important to take into account best practices tailored to the current context, software environment, or tools being used in version control or testing phases when considering whether these guidelines are still applicable.

In general, maintaining a knowledge base and updated references list regarding common coding patterns is highly recommended.

Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/app-store/apps/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ const openInstall = (app: App.App) => {
case 'java':
case 'go':
case 'python':
case 'donet':
router.push({ path: '/websites/runtimes/' + app.type });
break;
default:
Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/app-store/detail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const openInstall = () => {
case 'java':
case 'go':
case 'python':
case 'donet':
router.push({ path: '/websites/runtimes/' + app.value.type });
break;
default:
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/views/home/app/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ const acceptParams = (): void => {
const goInstall = (key: string, type: string) => {
switch (type) {
case 'php':
router.push({ path: '/websites/runtimes/php' });
break;
case 'node':
router.push({ path: '/websites/runtimes/node' });
case 'java':
case 'go':
case 'python':
case 'donet':
router.push({ path: '/websites/runtimes/' + type });
break;
default:
router.push({ name: 'AppAll', query: { install: key } });
Expand Down
Loading
Loading