fix 镜像创建容器支持配置 hostname、集群服务支持配置 hostname

This commit is contained in:
bwcx_jzy 2023-05-12 19:52:06 +08:00
parent 0203796d5b
commit 2280935400
No known key found for this signature in database
GPG Key ID: E187D6E9DDDE8C53
6 changed files with 15 additions and 3 deletions

View File

@ -5,6 +5,7 @@
### 🐣 新增功能 ### 🐣 新增功能
1. 【server】新增 仓库支持导入导出 1. 【server】新增 仓库支持导入导出
2. 【server】新增 镜像创建容器支持配置 hostname、集群服务支持配置 hostname感谢@心光)
### 🐞 解决BUG、优化功能 ### 🐞 解决BUG、优化功能

View File

@ -55,4 +55,4 @@ ADD,SCRIPT_EXECUTE_LOG,nodeName,String,50,,节点名称,false
ADD,SCRIPT_INFO,workspaceName,String,50,,工作空间名称,false ADD,SCRIPT_INFO,workspaceName,String,50,,工作空间名称,false
ADD,PROJECT_INFO,workspaceName,String,50,,工作空间名称,false ADD,PROJECT_INFO,workspaceName,String,50,,工作空间名称,false
ADD,SCRIPT_EXECUTE_LOG,workspaceName,String,50,,工作空间名称,false ADD,SCRIPT_EXECUTE_LOG,workspaceName,String,50,,工作空间名称,false
ALTER,REPOSITORY,password,String,255,,登录密码,true ALTER,REPOSITORY,password,String,255,,登录密码,false

1 alterType,tableName,name,type,len,defaultValue,comment,notNull
55 ADD,SCRIPT_INFO,workspaceName,String,50,,工作空间名称,false
56 ADD,PROJECT_INFO,workspaceName,String,50,,工作空间名称,false
57 ADD,SCRIPT_EXECUTE_LOG,workspaceName,String,50,,工作空间名称,false
58 ALTER,REPOSITORY,password,String,255,,登录密码,true ALTER,REPOSITORY,password,String,255,,登录密码,false

View File

@ -273,7 +273,8 @@ public class DefaultDockerPluginImpl implements IDockerConfigPlugin {
return labelMap; return labelMap;
}) })
.ifPresent(containerCmd::withLabels); .ifPresent(containerCmd::withLabels);
String hostname = (String) parameter.get("hostname");
Opt.ofBlankAble(hostname).ifPresent(containerCmd::withHostName);
HostConfig hostConfig = HostConfig.newHostConfig(); HostConfig hostConfig = HostConfig.newHostConfig();
Opt.ofBlankAble(runtime).ifPresent(hostConfig::withRuntime); Opt.ofBlankAble(runtime).ifPresent(hostConfig::withRuntime);
List<ExposedPort> exposedPortList = new ArrayList<>(); List<ExposedPort> exposedPortList = new ArrayList<>();

View File

@ -25,6 +25,7 @@ package org.dromara.jpom;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.unit.DataSize; import cn.hutool.core.io.unit.DataSize;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.EnumUtil; import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
@ -325,7 +326,8 @@ public class DefaultDockerSwarmPluginImpl implements IDefaultPlugin {
private ContainerSpec buildContainerSpec(Map<String, Object> parameter, ContainerSpec oldContainerSpec) { private ContainerSpec buildContainerSpec(Map<String, Object> parameter, ContainerSpec oldContainerSpec) {
String image = (String) parameter.get("image"); String image = (String) parameter.get("image");
ContainerSpec containerSpec = ObjectUtil.defaultIfNull(oldContainerSpec, new ContainerSpec()); ContainerSpec containerSpec = ObjectUtil.defaultIfNull(oldContainerSpec, new ContainerSpec());
//new ContainerSpec(); String hostname = (String) parameter.get("hostname");
Opt.ofBlankAble(hostname).ifPresent(containerSpec::withHostname);
containerSpec.withImage(image); containerSpec.withImage(image);
// //
Collection<Map<String, String>> args = (Collection) parameter.get("args"); Collection<Map<String, String>> args = (Collection) parameter.get("args");

View File

@ -229,6 +229,9 @@
</a-col> </a-col>
</a-row> </a-row>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="hostname" prop="hostname">
<a-input v-model="temp.hostname" placeholder="主机名 hostname" />
</a-form-model-item>
<a-form-model-item label="网络"> <a-form-model-item label="网络">
<a-auto-complete v-model="temp.networkMode" placeholder="网络模式bridge、container:<name|id>、host、container、none" option-label-prop="value"> <a-auto-complete v-model="temp.networkMode" placeholder="网络模式bridge、container:<name|id>、host、container、none" option-label-prop="value">
<template slot="dataSource"> <template slot="dataSource">
@ -555,6 +558,7 @@ export default {
restartPolicy: this.temp.restartPolicy, restartPolicy: this.temp.restartPolicy,
labels: this.temp.labels, labels: this.temp.labels,
runtime: this.temp.runtime, runtime: this.temp.runtime,
hostname: this.temp.hostname,
storageOpt: {}, storageOpt: {},
}; };
temp.volumes = (this.temp.volumes || []) temp.volumes = (this.temp.volumes || [])

View File

@ -81,6 +81,9 @@
<a-form-model-item label="镜像名称" prop="image"> <a-form-model-item label="镜像名称" prop="image">
<a-input v-model="temp.image" placeholder="镜像名称" /> <a-input v-model="temp.image" placeholder="镜像名称" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="hostname" prop="hostname">
<a-input v-model="temp.hostname" placeholder="主机名 hostname" />
</a-form-model-item>
<a-form-model-item label="更多配置" prop=""> <a-form-model-item label="更多配置" prop="">
<a-tabs> <a-tabs>
<a-tab-pane key="port" tab="端口"> <a-tab-pane key="port" tab="端口">
@ -533,6 +536,7 @@ export default {
this.temp = { this.temp = {
serviceId: record.id, serviceId: record.id,
name: spec.name, name: spec.name,
hostname: spec.taskTemplate?.containerSpec?.hostname,
mode: spec.mode?.mode, mode: spec.mode?.mode,
replicas: spec.mode?.replicated?.replicas, replicas: spec.mode?.replicated?.replicas,
image: image, image: image,