From 9a43b52c6224f122473e51fbd6e45fdc419bff04 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 7 Sep 2023 16:24:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=B9=E5=99=A8=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20entrypoint=20=E5=8F=82=E6=95=B0=20(#2217)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/container.go | 1 + backend/app/service/container.go | 2 + frontend/src/api/interface/container.ts | 2 + frontend/src/lang/modules/en.ts | 4 +- frontend/src/lang/modules/tw.ts | 4 +- frontend/src/lang/modules/zh.ts | 4 +- .../container/container/operate/index.vue | 114 ++++++++++-------- 7 files changed, 77 insertions(+), 54 deletions(-) diff --git a/backend/app/dto/container.go b/backend/app/dto/container.go index b3c6343e9..20045b946 100644 --- a/backend/app/dto/container.go +++ b/backend/app/dto/container.go @@ -45,6 +45,7 @@ type ContainerOperate struct { PublishAllPorts bool `json:"publishAllPorts"` ExposedPorts []PortHelper `json:"exposedPorts"` Cmd []string `json:"cmd"` + Entrypoint []string `json:"entrypoint"` CPUShares int64 `json:"cpuShares"` NanoCPUs float64 `json:"nanoCPUs"` Memory float64 `json:"memory"` diff --git a/backend/app/service/container.go b/backend/app/service/container.go index 7767385ec..51c234da6 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -366,6 +366,7 @@ func (u *ContainerService) ContainerInfo(req dto.OperationWithName) (*dto.Contai } } data.Cmd = oldContainer.Config.Cmd + data.Entrypoint = oldContainer.Config.Entrypoint data.Env = oldContainer.Config.Env data.CPUShares = oldContainer.HostConfig.CPUShares for key, val := range oldContainer.Config.Labels { @@ -842,6 +843,7 @@ func loadConfigInfo(req dto.ContainerOperate, config *container.Config, hostConf } config.Image = req.Image config.Cmd = req.Cmd + config.Entrypoint = req.Entrypoint config.Env = req.Env config.Labels = stringsToMap(req.Labels) config.ExposedPorts = exposeds diff --git a/frontend/src/api/interface/container.ts b/frontend/src/api/interface/container.ts index 8c64db553..787e63fad 100644 --- a/frontend/src/api/interface/container.ts +++ b/frontend/src/api/interface/container.ts @@ -23,8 +23,10 @@ export namespace Container { forcePull: boolean; network: string; cmdStr: string; + entrypointStr: string; memoryItem: number; cmd: Array; + entrypoint: Array; publishAllPorts: boolean; exposedPorts: Array; nanoCPUs: number; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 3a13f6306..c6664c56d 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -543,8 +543,8 @@ const message = { containerExample: 'e.g. 80 or 80-88', exposePort: 'Expose port', exposeAll: 'Expose all', - cmd: 'Command', - cmdHelper: "Separate multiple commands with ' ' as delimiter, such as 'nginx' '-g' 'daemon off;'", + cmdHelper: "e.g. 'nginx' '-g' 'daemon off;' OR nginx -g daemon off;", + entrypointHelper: 'e.g. /bin/sh -c', autoRemove: 'Auto remove', cpuQuota: 'NacosCPU', memoryLimit: 'Memory', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index c605e0a96..3557e74b6 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -527,8 +527,8 @@ const message = { containerExample: '例: 80 或者 80-88', exposePort: '暴露端口', exposeAll: '暴露所有', - cmd: '啟動命令', - cmdHelper: "多個命令間請用 ' ' 分隔開,如 'nginx' '-g' 'daemon off;'", + cmdHelper: "例: 'nginx' '-g' 'daemon off;' 或 nginx -g daemon off;", + entrypointHelper: '例: /bin/sh -c', autoRemove: '容器退出後自動刪除容器', cpuQuota: 'CPU 限製', memoryLimit: '內存限製', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 79493061e..2263e2971 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -527,8 +527,8 @@ const message = { containerExample: '例: 80 或者 80-88', exposePort: '暴露端口', exposeAll: '暴露所有', - cmd: '启动命令', - cmdHelper: "多个命令间请用 ' ' 分隔开,如 'nginx' '-g' 'daemon off;'", + cmdHelper: "例: 'nginx' '-g' 'daemon off;' 或者 nginx -g daemon off;", + entrypointHelper: '例: /bin/sh -c', autoRemove: '容器退出后自动删除容器', cpuQuota: 'CPU 限制', memoryLimit: '内存限制', diff --git a/frontend/src/views/container/container/operate/index.vue b/frontend/src/views/container/container/operate/index.vue index f42968d06..e0de63056 100644 --- a/frontend/src/views/container/container/operate/index.vue +++ b/frontend/src/views/container/container/operate/index.vue @@ -109,39 +109,6 @@ /> - - - {{ $t('container.cmdHelper') }} - - - - {{ $t('container.autoRemove') }} - - - - - {{ $t('container.cpuShareHelper') }} - - - - - - - {{ $t('container.limitHelper', [limits.cpu]) }}{{ $t('commons.units.core') }} - - - - - - - {{ $t('container.limitHelper', [limits.memory]) }}MB - @@ -167,12 +134,14 @@ filterable v-model="row.sourceDir" > - +
+ + + +
@@ -200,6 +169,52 @@
+ + + + + + + + + {{ $t('container.autoRemove') }} + + + + + {{ $t('container.no') }} + {{ $t('container.always') }} + {{ $t('container.onFailure') }} + {{ $t('container.unlessStopped') }} + + + + + {{ $t('container.cpuShareHelper') }} + + + + + + + {{ $t('container.limitHelper', [limits.cpu]) }}{{ $t('commons.units.core') }} + + + + + + + {{ $t('container.limitHelper', [limits.memory]) }}MB + - - - {{ $t('container.no') }} - {{ $t('container.always') }} - {{ $t('container.onFailure') }} - {{ $t('container.unlessStopped') }} - - @@ -282,6 +289,9 @@ const acceptParams = (params: DialogProps): void => { itemCmd += `'${item}' `; } dialogData.value.rowData.cmdStr = itemCmd ? itemCmd.substring(0, itemCmd.length - 1) : ''; + if (dialogData.value.rowData.entrypoint) { + dialogData.value.rowData.entrypointStr = dialogData.value.rowData.entrypoint.join(' '); + } dialogData.value.rowData.labels = dialogData.value.rowData.labels || []; dialogData.value.rowData.env = dialogData.value.rowData.env || []; dialogData.value.rowData.labelsStr = dialogData.value.rowData.labels.join('\n'); @@ -391,13 +401,21 @@ const onSubmit = async (formEl: FormInstance | undefined) => { dialogData.value.rowData!.labels = dialogData.value.rowData!.labelsStr.split('\n'); } dialogData.value.rowData!.cmd = []; - if (dialogData.value.rowData?.cmdStr) { + if (dialogData.value.rowData?.cmdStr.indexOf(`'`) !== -1) { let itemCmd = dialogData.value.rowData!.cmdStr.split(`'`); for (const cmd of itemCmd) { if (cmd && cmd !== ' ') { dialogData.value.rowData!.cmd.push(cmd); } } + } else { + let itemCmd = dialogData.value.rowData!.cmdStr.split(` `); + for (const cmd of itemCmd) { + dialogData.value.rowData!.cmd.push(cmd); + } + } + if (dialogData.value.rowData!.entrypointStr) { + dialogData.value.rowData!.entrypoint = dialogData.value.rowData!.entrypointStr.split(' '); } if (!checkPortValid()) { return;