diff --git a/agent/app/dto/request/runtime.go b/agent/app/dto/request/runtime.go index 8e6045f588a2..f8e1e6174fd3 100644 --- a/agent/app/dto/request/runtime.go +++ b/agent/app/dto/request/runtime.go @@ -27,7 +27,6 @@ type RuntimeCreate struct { type NodeConfig struct { Install bool `json:"install"` Clean bool `json:"clean"` - Port int `json:"port"` ExposedPorts []ExposedPort `json:"exposedPorts"` Environments []Environment `json:"environments"` Volumes []Volume `json:"volumes"` diff --git a/agent/app/model/runtime.go b/agent/app/model/runtime.go index aeec498e98ca..0970b9cc03e6 100644 --- a/agent/app/model/runtime.go +++ b/agent/app/model/runtime.go @@ -9,7 +9,7 @@ import ( type Runtime struct { BaseModel Name string `gorm:"not null" json:"name"` - AppDetailID uint `json:"appDetailId"` + AppDetailID uint `json:"appDetailID"` Image string `json:"image"` WorkDir string `json:"workDir"` DockerCompose string `json:"dockerCompose"` diff --git a/agent/app/service/runtime.go b/agent/app/service/runtime.go index 1cd268c4449f..dbd945c7202f 100644 --- a/agent/app/service/runtime.go +++ b/agent/app/service/runtime.go @@ -109,26 +109,23 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e if exist != nil { return nil, buserr.New(constant.ErrImageExist) } - portValue, _ := create.Params["PANEL_APP_PORT_HTTP"] - if portValue != nil { - if err := checkPortExist(int(portValue.(float64))); err != nil { - return nil, err - } - } case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet: if !fileOp.Stat(create.CodeDir) { return nil, buserr.New(constant.ErrPathNotFound) } create.Install = true - if err := checkPortExist(create.Port); err != nil { - return nil, err - } for _, export := range create.ExposedPorts { if err := checkPortExist(export.HostPort); err != nil { return nil, err } } } + portValue, _ := create.Params["PANEL_APP_PORT_HTTP"] + if portValue != nil { + if err := checkPortExist(int(portValue.(float64))); err != nil { + return nil, err + } + } containerName, ok := create.Params["CONTAINER_NAME"] if !ok { return nil, buserr.New("ErrContainerNameIsNull") @@ -161,17 +158,16 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e Resource: create.Resource, Version: create.Version, ContainerName: containerName.(string), + Port: int(portValue.(float64)), } switch create.Type { case constant.RuntimePHP: - runtime.Port = int(create.Params["PANEL_APP_PORT_HTTP"].(float64)) if err = handlePHP(create, runtime, fileOp, appVersionDir); err != nil { return nil, err } case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet: - runtime.Port = int(create.Params["port"].(float64)) - if err = handleNodeAndJava(create, runtime, fileOp, appVersionDir); err != nil { + if err = handleRuntime(create, runtime, fileOp, appVersionDir); err != nil { return nil, err } } @@ -356,7 +352,7 @@ func (r *RuntimeService) Get(id uint) (*response.RuntimeDTO, error) { } for k, v := range envs { switch k { - case "NODE_APP_PORT", "PANEL_APP_PORT_HTTP", "JAVA_APP_PORT", "GO_APP_PORT", "APP_PORT", "port": + case "APP_PORT", "PANEL_APP_PORT_HTTP": port, err := strconv.Atoi(v) if err != nil { return nil, err @@ -440,7 +436,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error { } oldImage := runtime.Image oldEnv := runtime.Env - req.Port = int(req.Params["port"].(float64)) + port := int(req.Params["PANEL_APP_PORT_HTTP"].(float64)) switch runtime.Type { case constant.RuntimePHP: exist, _ := runtimeRepo.GetFirst(runtimeRepo.WithImage(req.Name), runtimeRepo.WithNotId(req.ID)) @@ -448,11 +444,11 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error { return buserr.New(constant.ErrImageExist) } case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet: - if runtime.Port != req.Port { - if err = checkPortExist(req.Port); err != nil { + if runtime.Port != port { + if err = checkPortExist(port); err != nil { return err } - runtime.Port = req.Port + runtime.Port = port } for _, export := range req.ExposedPorts { if err = checkPortExist(export.HostPort); err != nil { @@ -494,7 +490,6 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error { CodeDir: req.CodeDir, Version: req.Version, NodeConfig: request.NodeConfig{ - Port: req.Port, Install: true, ExposedPorts: req.ExposedPorts, Environments: req.Environments, @@ -526,7 +521,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error { case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet: runtime.Version = req.Version runtime.CodeDir = req.CodeDir - runtime.Port = req.Port + runtime.Port = port runtime.Status = constant.RuntimeReCreating _ = runtimeRepo.Save(runtime) go reCreateRuntime(runtime) diff --git a/agent/app/service/runtime_utils.go b/agent/app/service/runtime_utils.go index aaf807cc923d..4f6b93e7b15d 100644 --- a/agent/app/service/runtime_utils.go +++ b/agent/app/service/runtime_utils.go @@ -30,7 +30,7 @@ import ( "time" ) -func handleNodeAndJava(create request.RuntimeCreate, runtime *model.Runtime, fileOp files.FileOp, appVersionDir string) (err error) { +func handleRuntime(create request.RuntimeCreate, runtime *model.Runtime, fileOp files.FileOp, appVersionDir string) (err error) { runtimeDir := path.Join(constant.RuntimeDir, create.Type) if err = fileOp.CopyDir(appVersionDir, runtimeDir); err != nil { return @@ -356,14 +356,12 @@ func handleParams(create request.RuntimeCreate, projectDir string) (composeConte case constant.RuntimeNode: create.Params["CODE_DIR"] = create.CodeDir create.Params["NODE_VERSION"] = create.Version - create.Params["PANEL_APP_PORT_HTTP"] = create.Port if create.NodeConfig.Install { create.Params["RUN_INSTALL"] = "1" } else { create.Params["RUN_INSTALL"] = "0" } create.Params["CONTAINER_PACKAGE_URL"] = create.Source - create.Params["NODE_APP_PORT"] = create.Params["APP_PORT"] composeContent, err = handleCompose(env, composeContent, create, projectDir) if err != nil { return @@ -371,8 +369,6 @@ func handleParams(create request.RuntimeCreate, projectDir string) (composeConte case constant.RuntimeJava: create.Params["CODE_DIR"] = create.CodeDir create.Params["JAVA_VERSION"] = create.Version - create.Params["PANEL_APP_PORT_HTTP"] = create.Port - create.Params["JAVA_APP_PORT"] = create.Params["APP_PORT"] composeContent, err = handleCompose(env, composeContent, create, projectDir) if err != nil { return @@ -380,8 +376,6 @@ func handleParams(create request.RuntimeCreate, projectDir string) (composeConte case constant.RuntimeGo: create.Params["CODE_DIR"] = create.CodeDir create.Params["GO_VERSION"] = create.Version - create.Params["PANEL_APP_PORT_HTTP"] = create.Port - create.Params["GO_APP_PORT"] = create.Params["APP_PORT"] composeContent, err = handleCompose(env, composeContent, create, projectDir) if err != nil { return @@ -389,7 +383,6 @@ func handleParams(create request.RuntimeCreate, projectDir string) (composeConte case constant.RuntimePython: create.Params["CODE_DIR"] = create.CodeDir create.Params["PYTHON_VERSION"] = create.Version - create.Params["PANEL_APP_PORT_HTTP"] = create.Port composeContent, err = handleCompose(env, composeContent, create, projectDir) if err != nil { return @@ -397,7 +390,6 @@ func handleParams(create request.RuntimeCreate, projectDir string) (composeConte case constant.RuntimeDotNet: create.Params["CODE_DIR"] = create.CodeDir create.Params["DOTNET_VERSION"] = create.Version - create.Params["PANEL_APP_PORT_HTTP"] = create.Port composeContent, err = handleCompose(env, composeContent, create, projectDir) if err != nil { return @@ -440,17 +432,7 @@ func handleCompose(env gotenv.Env, composeContent []byte, create request.Runtime _, ok := serviceValue["ports"].([]interface{}) if ok { var ports []interface{} - switch create.Type { - case constant.RuntimeNode: - ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${NODE_APP_PORT}") - case constant.RuntimeJava: - 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, constant.RuntimeDotNet: - ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${APP_PORT}") - - } + ports = append(ports, "${HOST_IP}:${PANEL_APP_PORT_HTTP}:${APP_PORT}") for i, port := range create.ExposedPorts { containerPortStr := fmt.Sprintf("CONTAINER_PORT_%d", i) hostPortStr := fmt.Sprintf("HOST_PORT_%d", i) diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 48c33a58aa4c..6e8b8223b62e 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -2374,7 +2374,7 @@ const message = { appPort: '应用端口', externalPort: '外部映射端口', packageManager: '包管理器', - codeDir: '源码目录', + codeDir: '项目目录', appPortHelper: '应用端口是指容器内部的端口', externalPortHelper: '外部映射端口是指容器对外暴露的端口', runScript: '启动命令', diff --git a/frontend/src/views/website/runtime/app/index.vue b/frontend/src/views/website/runtime/app/index.vue new file mode 100644 index 000000000000..dc156297e4f3 --- /dev/null +++ b/frontend/src/views/website/runtime/app/index.vue @@ -0,0 +1,119 @@ + + + diff --git a/frontend/src/views/website/runtime/dir/index.vue b/frontend/src/views/website/runtime/dir/index.vue new file mode 100644 index 000000000000..971e69be5196 --- /dev/null +++ b/frontend/src/views/website/runtime/dir/index.vue @@ -0,0 +1,136 @@ + + + diff --git a/frontend/src/views/website/runtime/dotnet/index.vue b/frontend/src/views/website/runtime/dotnet/index.vue index 98f022eaa49b..fa2a6f68a5d1 100644 --- a/frontend/src/views/website/runtime/dotnet/index.vue +++ b/frontend/src/views/website/runtime/dotnet/index.vue @@ -15,10 +15,6 @@ {{ $t('runtime.create') }} - - - {{ $t('container.cleanBuildCache') }} -