From 388458f759acb6ca53a9313586eee4729dfb49d9 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 14 Nov 2025 18:22:49 +0800 Subject: [PATCH] feat: Image build supports setting build parameters (#10960) Refs #10898 --- agent/app/dto/image.go | 1 + agent/app/service/container.go | 10 ++++++++++ agent/app/service/image.go | 1 + frontend/src/api/interface/container.ts | 1 + frontend/src/lang/modules/en.ts | 2 +- frontend/src/lang/modules/es-es.ts | 2 +- frontend/src/lang/modules/ja.ts | 2 +- frontend/src/lang/modules/ko.ts | 2 +- frontend/src/lang/modules/ms.ts | 2 +- frontend/src/lang/modules/pt-br.ts | 2 +- frontend/src/lang/modules/ru.ts | 2 +- frontend/src/lang/modules/tr.ts | 2 +- frontend/src/lang/modules/zh-Hant.ts | 2 +- frontend/src/lang/modules/zh.ts | 2 +- frontend/src/views/container/image/build/index.vue | 9 +++++++++ 15 files changed, 32 insertions(+), 10 deletions(-) diff --git a/agent/app/dto/image.go b/agent/app/dto/image.go index 304dd0f83..192e5974c 100644 --- a/agent/app/dto/image.go +++ b/agent/app/dto/image.go @@ -28,6 +28,7 @@ type ImageBuild struct { Name string `json:"name" validate:"required"` Dockerfile string `json:"dockerfile" validate:"required"` Tags []string `json:"tags"` + Args []string `json:"args"` } type ImagePull struct { diff --git a/agent/app/service/container.go b/agent/app/service/container.go index 7f41c07ac..03deebe8c 100644 --- a/agent/app/service/container.go +++ b/agent/app/service/container.go @@ -1256,6 +1256,16 @@ func stringsToMap(list []string) map[string]string { } return labelMap } +func stringsToMap2(list []string) map[string]*string { + var labelMap = make(map[string]*string) + for _, label := range list { + if strings.Contains(label, "=") { + sps := strings.SplitN(label, "=", 2) + labelMap[sps[0]] = &sps[1] + } + } + return labelMap +} func calculateCPUPercentUnix(stats *container.StatsResponse) float64 { cpuPercent := 0.0 diff --git a/agent/app/service/image.go b/agent/app/service/image.go index e8b31e02d..5389e190a 100644 --- a/agent/app/service/image.go +++ b/agent/app/service/image.go @@ -228,6 +228,7 @@ func (u *ImageService) ImageBuild(req dto.ImageBuild) error { Tags: []string{req.Name}, Remove: true, Labels: stringsToMap(req.Tags), + BuildArgs: stringsToMap2(req.Args), } taskItem, err := task.NewTaskWithOps(req.Name, task.TaskBuild, task.TaskScopeImage, req.TaskID, 1) if err != nil { diff --git a/frontend/src/api/interface/container.ts b/frontend/src/api/interface/container.ts index 9072d9187..310beec71 100644 --- a/frontend/src/api/interface/container.ts +++ b/frontend/src/api/interface/container.ts @@ -187,6 +187,7 @@ export namespace Container { name: string; dockerfile: string; tags: Array; + args: Array; } export interface ImagePull { taskID: string; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index a168e5508..72e503155 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -925,7 +925,7 @@ const message = { pull: 'Pull', path: 'Path', importImage: 'Import', - build: 'Build', + buildArgs: 'Build Arguments', imageBuild: 'Build', pathSelect: 'Path', label: 'Label', diff --git a/frontend/src/lang/modules/es-es.ts b/frontend/src/lang/modules/es-es.ts index 0666489b8..b0c66b248 100644 --- a/frontend/src/lang/modules/es-es.ts +++ b/frontend/src/lang/modules/es-es.ts @@ -930,7 +930,7 @@ const message = { pull: 'Descargar', path: 'Ruta', importImage: 'Importar', - build: 'Construir', + buildArgs: 'Argumentos de Construcción', imageBuild: 'Construir', pathSelect: 'Ruta', label: 'Etiqueta', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 119169386..21194661f 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -902,7 +902,7 @@ const message = { pull: '引く', path: 'パス', importImage: '輸入', - build: '建てる', + buildArgs: 'ビルド引数', imageBuild: '建てる', pathSelect: 'パス', label: 'ラベル', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index fc31fe70c..c74ae60f5 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -893,7 +893,7 @@ const message = { pull: '풀', path: '경로', importImage: '가져오기', - build: '빌드', + buildArgs: '빌드 인수', imageBuild: '이미지 빌드', pathSelect: '경로', label: '레이블', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index 454a22186..9460339a3 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -918,7 +918,7 @@ const message = { pull: 'Tarik', path: 'Laluan', importImage: 'Import', - build: 'Bina', + buildArgs: 'Argumen Binaan', imageBuild: 'Bina', pathSelect: 'Laluan', label: 'Label', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index ec99449d7..ad2733ce4 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -915,7 +915,7 @@ const message = { pull: 'Puxar', path: 'Caminho', importImage: 'Importar', - build: 'Construir', + buildArgs: 'Argumentos de Build', imageBuild: 'Construção de imagem', pathSelect: 'Caminho', label: 'Etiqueta', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index e9851c539..995160fb0 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -915,7 +915,7 @@ const message = { pull: 'Загрузить', path: 'Путь', importImage: 'Импорт', - build: 'Сборка', + buildArgs: 'Аргументы Сборки', imageBuild: 'Сборка', pathSelect: 'Путь', label: 'Метка', diff --git a/frontend/src/lang/modules/tr.ts b/frontend/src/lang/modules/tr.ts index a6c3a2849..0fc41f2e1 100644 --- a/frontend/src/lang/modules/tr.ts +++ b/frontend/src/lang/modules/tr.ts @@ -934,7 +934,7 @@ const message = { pull: 'Çek', path: 'Yol', importImage: 'İçe aktar', - build: 'Oluştur', + buildArgs: 'Derleme Argümanları', imageBuild: 'Oluştur', pathSelect: 'Yol', label: 'Etiket', diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts index c6bf82347..a052e7d91 100644 --- a/frontend/src/lang/modules/zh-Hant.ts +++ b/frontend/src/lang/modules/zh-Hant.ts @@ -886,7 +886,7 @@ const message = { path: '路徑', importImage: '匯入鏡像', imageBuild: '構建鏡像', - build: '構建鏡像', + buildArgs: '構建參數', pathSelect: '路徑選擇', label: '標籤', imageTag: '鏡像標籤', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index fed0a33b1..059fd5d77 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -887,7 +887,7 @@ const message = { path: '路径', importImage: '导入镜像', imageBuild: '构建镜像', - build: '构建镜像', + buildArgs: '构建参数', pathSelect: '路径选择', label: '标签', imageTag: '镜像标签', diff --git a/frontend/src/views/container/image/build/index.vue b/frontend/src/views/container/image/build/index.vue index ef9fa4971..c3ae53118 100644 --- a/frontend/src/views/container/image/build/index.vue +++ b/frontend/src/views/container/image/build/index.vue @@ -31,6 +31,9 @@ + + + @@ -71,6 +74,8 @@ const form = reactive({ name: '', tagStr: '', tags: [] as Array, + argStr: '', + args: [] as Array, }); const rules = reactive({ @@ -83,6 +88,7 @@ const acceptParams = async () => { form.from = 'path'; form.dockerfile = ''; form.tagStr = ''; + form.argStr = ''; form.name = ''; }; const emit = defineEmits<{ (e: 'search'): void }>(); @@ -102,6 +108,9 @@ const onSubmit = async (formEl: FormInstance | undefined) => { if (form.tagStr !== '') { form.tags = form.tagStr.split('\n'); } + if (form.argStr !== '') { + form.args = form.argStr.split('\n'); + } form.taskID = newUUID(); await imageBuild(form); openTaskLog(form.taskID);