🔨 perf(server): 容器构建执行配置自定义 host 参数

This commit is contained in:
小吾立 2024-05-30 15:12:29 +08:00
parent f76d3043ad
commit eb908f87a7
5 changed files with 75 additions and 32 deletions

View File

@ -10,6 +10,7 @@
### 🐞 解决BUG、优化功能
1. 【server】优化 自动续签采用无感模式(感谢@湘江夜色)
2. 【server】优化 容器构建执行配置自定义 host 参数(感谢@冰淇淋还是冰激凌)
------

View File

@ -249,6 +249,8 @@ public class DefaultDockerPluginImpl implements IDockerConfigPlugin {
Map<String, String> storageOpt = (Map<String, String>) parameter.get("storageOpt");
String labels = (String) parameter.get("labels");
String runtime = (String) parameter.get("runtime");
List<String> extraHosts = (List<String>) parameter.get("extraHosts");
//
CreateContainerCmd containerCmd = dockerClient.createContainerCmd(imageId);
containerCmd.withName(name);
@ -267,6 +269,11 @@ public class DefaultDockerPluginImpl implements IDockerConfigPlugin {
Opt.ofBlankAble(hostname).ifPresent(containerCmd::withHostName);
HostConfig hostConfig = HostConfig.newHostConfig();
Opt.ofBlankAble(runtime).ifPresent(hostConfig::withRuntime);
//
Opt.ofBlankAble(extraHosts).ifPresent(list -> {
String[] array = list.stream().filter(StrUtil::isNotEmpty).toArray(String[]::new);
hostConfig.withExtraHosts(array);
});
List<ExposedPort> exposedPortList = new ArrayList<>();
if (StrUtil.isNotEmpty(exposedPorts)) {
List<PortBinding> portBindings = StrUtil.splitTrim(exposedPorts, StrUtil.COMMA)

View File

@ -73,10 +73,10 @@ const pageLoadingTimeout = ref()
const useAppStore = appStore()
const pageLoading = computed(() => {
const pageLoadingStore = computed(() => {
return useAppStore.loading
})
watch(pageLoading, (newValue) => {
watch(pageLoadingStore, (newValue) => {
//
if (newValue === 2) {
clearTimeout(pageLoadingTimeout.value)

View File

@ -156,7 +156,6 @@ instance.interceptors.response.use(
* @param config AxiosRequestConfig
* @returns IResponse<T>
*/
async function request<T = any>(url: string, config?: AxiosRequestConfig): Promise<IResponse<T>>
// eslint-disable-next-line no-redeclare
async function request<T = any>(config: AxiosRequestConfig): Promise<IResponse<T>>

View File

@ -288,8 +288,40 @@
</template>
</a-auto-complete>
</a-form-item>
<a-form-item label="自定义 host">
<a-form-item-rest>
<a-space direction="vertical" style="width: 100%">
<a-row v-for="(item, index) in temp.extraHosts" :key="index">
<a-col :span="20">
<a-input v-model:value="temp.extraHosts[index]" placeholder="自定义host, xxx:192.168.0.x" />
</a-col>
<a-col :span="2" :offset="1">
<a-space>
<MinusCircleOutlined
v-if="temp.extraHosts && temp.extraHosts.length > 1"
@click="
() => {
temp.extraHosts.splice(index, 1)
}
"
/>
<PlusSquareOutlined
@click="
() => {
temp.extraHosts.push('')
}
"
/>
</a-space>
</a-col>
</a-row>
</a-space>
</a-form-item-rest>
</a-form-item>
<a-form-item :label="$tl('p.storageOptions')">
<a-form-item-rest>
<a-space direction="vertical" style="width: 100%">
<a-row v-for="(item, index) in temp.storageOpt" :key="index">
<a-col :span="10">
<a-input v-model:value="item.key" :placeholder="$tl('p.configName')" />
@ -318,6 +350,7 @@
</a-space>
</a-col>
</a-row>
</a-space>
</a-form-item-rest>
</a-form-item>
<a-form-item label="runtime">
@ -569,6 +602,7 @@ export default {
networkMode: res.data?.hostConfig?.networkMode,
runtime: res.data?.hostConfig?.runtime,
privileged: res.data.hostConfig?.privileged || false,
extraHosts: res.data?.hostConfig?.extraHosts || [''],
...this.temp
}
this.$refs['editForm']?.resetFields()
@ -595,7 +629,8 @@ export default {
imageId: this.imageId,
env: [{}],
storageOpt: [{}],
commands: [{}]
commands: [{}],
extraHosts: ['']
}
this.$refs['editForm']?.resetFields()
})
@ -616,7 +651,8 @@ export default {
labels: this.temp.labels,
runtime: this.temp.runtime,
hostname: this.temp.hostname,
storageOpt: {}
storageOpt: {},
extraHosts: this.temp.extraHosts
}
temp.volumes = (this.temp.volumes || [])
.filter((item) => {