mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-12-21 07:49:08 +08:00
feat: changeWorkdir option for docker
This commit is contained in:
parent
0bd617d5ed
commit
137808048d
common
daemon/src
frontend/src
1
common/global.d.ts
vendored
1
common/global.d.ts
vendored
@ -74,6 +74,7 @@ export interface IGlobalInstanceDockerConfig {
|
|||||||
cpuUsage?: number;
|
cpuUsage?: number;
|
||||||
workingDir?: string;
|
workingDir?: string;
|
||||||
env?: string[];
|
env?: string[];
|
||||||
|
changeWorkdir?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPanelResponseProtocol {
|
export interface IPanelResponseProtocol {
|
||||||
|
@ -66,7 +66,8 @@ export default class InstanceConfig implements IGlobalInstanceConfig {
|
|||||||
io: 0,
|
io: 0,
|
||||||
network: 0,
|
network: 0,
|
||||||
workingDir: "/workspace/",
|
workingDir: "/workspace/",
|
||||||
env: []
|
env: [],
|
||||||
|
changeWorkdir: false
|
||||||
};
|
};
|
||||||
|
|
||||||
public pingConfig = {
|
public pingConfig = {
|
||||||
|
@ -209,6 +209,7 @@ export default class Instance extends EventEmitter {
|
|||||||
configureEntityParams(this.config.docker, cfg.docker, "cpuUsage", Number);
|
configureEntityParams(this.config.docker, cfg.docker, "cpuUsage", Number);
|
||||||
configureEntityParams(this.config.docker, cfg.docker, "env");
|
configureEntityParams(this.config.docker, cfg.docker, "env");
|
||||||
configureEntityParams(this.config.docker, cfg.docker, "workingDir", String);
|
configureEntityParams(this.config.docker, cfg.docker, "workingDir", String);
|
||||||
|
configureEntityParams(this.config.docker, cfg.docker, "changeWorkdir", Boolean);
|
||||||
}
|
}
|
||||||
if (cfg.pingConfig) {
|
if (cfg.pingConfig) {
|
||||||
configureEntityParams(this.config.pingConfig, cfg.pingConfig, "ip", String);
|
configureEntityParams(this.config.pingConfig, cfg.pingConfig, "ip", String);
|
||||||
|
@ -175,7 +175,7 @@ export class SetupDockerContainer extends AsyncTask {
|
|||||||
AttachStdout: true,
|
AttachStdout: true,
|
||||||
AttachStderr: true,
|
AttachStderr: true,
|
||||||
Tty: isTty,
|
Tty: isTty,
|
||||||
WorkingDir: workingDir,
|
WorkingDir: instance.config.docker.changeWorkdir ? workingDir : undefined,
|
||||||
Cmd: commandList.length > 0 ? commandList : undefined,
|
Cmd: commandList.length > 0 ? commandList : undefined,
|
||||||
OpenStdin: true,
|
OpenStdin: true,
|
||||||
StdinOnce: false,
|
StdinOnce: false,
|
||||||
|
@ -16,6 +16,7 @@ interface Props extends MountComponent {
|
|||||||
data: any[];
|
data: any[];
|
||||||
subTitle?: string;
|
subTitle?: string;
|
||||||
columns?: AntColumnsType[];
|
columns?: AntColumnsType[];
|
||||||
|
textarea?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
@ -92,7 +93,7 @@ const operation = (type: "add" | "del", index = 0) => {
|
|||||||
<a-modal
|
<a-modal
|
||||||
v-model:open="open"
|
v-model:open="open"
|
||||||
centered
|
centered
|
||||||
width="600px"
|
width="1300px"
|
||||||
:mask-closable="false"
|
:mask-closable="false"
|
||||||
:title="props.title"
|
:title="props.title"
|
||||||
:ok-text="t('TXT_CODE_d507abff')"
|
:ok-text="t('TXT_CODE_d507abff')"
|
||||||
@ -135,7 +136,15 @@ const operation = (type: "add" | "del", index = 0) => {
|
|||||||
}
|
}
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
|
<a-textarea
|
||||||
|
v-if="props.textarea"
|
||||||
|
v-model:value="record[String(column.dataIndex)]"
|
||||||
|
:placeholder="(column as any).placeholder"
|
||||||
|
:rows="3"
|
||||||
|
:auto-size="false"
|
||||||
|
/>
|
||||||
<a-input
|
<a-input
|
||||||
|
v-else
|
||||||
v-model:value="record[String(column.dataIndex)]"
|
v-model:value="record[String(column.dataIndex)]"
|
||||||
:placeholder="(column as any).placeholder"
|
:placeholder="(column as any).placeholder"
|
||||||
/>
|
/>
|
||||||
|
@ -80,7 +80,8 @@ export async function usePortEditDialog(data: PortConfigItem[] = []) {
|
|||||||
title: t("TXT_CODE_ad1c674c"),
|
title: t("TXT_CODE_ad1c674c"),
|
||||||
placeholder: "tcp/udp"
|
placeholder: "tcp/udp"
|
||||||
}
|
}
|
||||||
] as AntColumnsType[]
|
] as AntColumnsType[],
|
||||||
|
textarea: false
|
||||||
}).mount<PortConfigItem[]>(KvOptionsDialogVue)) || []
|
}).mount<PortConfigItem[]>(KvOptionsDialogVue)) || []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -102,7 +103,8 @@ export async function useVolumeEditDialog(data: DockerConfigItem[] = []) {
|
|||||||
dataIndex: "container",
|
dataIndex: "container",
|
||||||
title: t("TXT_CODE_30258325")
|
title: t("TXT_CODE_30258325")
|
||||||
}
|
}
|
||||||
] as AntColumnsType[]
|
] as AntColumnsType[],
|
||||||
|
textarea: true
|
||||||
}).mount<DockerConfigItem[]>(KvOptionsDialogVue)) || []
|
}).mount<DockerConfigItem[]>(KvOptionsDialogVue)) || []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -123,7 +125,8 @@ export async function useDockerEnvEditDialog(data: DockerEnvItem[] = []) {
|
|||||||
dataIndex: "value",
|
dataIndex: "value",
|
||||||
title: t("TXT_CODE_115e8a25")
|
title: t("TXT_CODE_115e8a25")
|
||||||
}
|
}
|
||||||
] as AntColumnsType[]
|
] as AntColumnsType[],
|
||||||
|
textarea: true
|
||||||
}).mount<DockerEnvItem[]>(KvOptionsDialogVue)) || []
|
}).mount<DockerEnvItem[]>(KvOptionsDialogVue)) || []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ defineExpose({
|
|||||||
:cancel-text="t('TXT_CODE_3b1cc020')"
|
:cancel-text="t('TXT_CODE_3b1cc020')"
|
||||||
:ok-text="t('TXT_CODE_abfe9512')"
|
:ok-text="t('TXT_CODE_abfe9512')"
|
||||||
:mask-closable="false"
|
:mask-closable="false"
|
||||||
:width="fullScreen ? '100%' : '1300px'"
|
:width="fullScreen ? '100%' : '1600px'"
|
||||||
:confirm-loading="isLoading"
|
:confirm-loading="isLoading"
|
||||||
@ok="submit"
|
@ok="submit"
|
||||||
@cancel="cancel"
|
@cancel="cancel"
|
||||||
|
@ -227,10 +227,6 @@ const encodeFormData = () => {
|
|||||||
throw new Error("Ref Options is null");
|
throw new Error("Ref Options is null");
|
||||||
};
|
};
|
||||||
|
|
||||||
const openCmdAssistDialog = async () => {
|
|
||||||
const cmd = await useCmdAssistantDialog();
|
|
||||||
if (options.value && cmd) options.value.config.startCommand = cmd;
|
|
||||||
};
|
|
||||||
const handleEditDockerConfig = async (type: "port" | "volume" | "env") => {
|
const handleEditDockerConfig = async (type: "port" | "volume" | "env") => {
|
||||||
if (type === "port" && options.value?.config) {
|
if (type === "port" && options.value?.config) {
|
||||||
// "25565:25565/tcp 8080:8080/tcp" -> Array
|
// "25565:25565/tcp 8080:8080/tcp" -> Array
|
||||||
@ -277,7 +273,7 @@ defineExpose({
|
|||||||
v-model:open="open"
|
v-model:open="open"
|
||||||
centered
|
centered
|
||||||
:mask-closable="false"
|
:mask-closable="false"
|
||||||
:width="isPhone ? '100%' : 'calc(100% - 30vw)'"
|
:width="isPhone ? '100%' : '1600px'"
|
||||||
:title="t('TXT_CODE_aac98b2a')"
|
:title="t('TXT_CODE_aac98b2a')"
|
||||||
:confirm-loading="isLoading"
|
:confirm-loading="isLoading"
|
||||||
:ok-text="t('TXT_CODE_abfe9512')"
|
:ok-text="t('TXT_CODE_abfe9512')"
|
||||||
@ -381,10 +377,12 @@ defineExpose({
|
|||||||
v-model:value="options.config.startCommand"
|
v-model:value="options.config.startCommand"
|
||||||
:rows="5"
|
:rows="5"
|
||||||
style="min-height: 40px"
|
style="min-height: 40px"
|
||||||
|
:placeholder="
|
||||||
|
options.config.docker.image
|
||||||
|
? t('留空将使用 Docker 镜像自带命令启动')
|
||||||
|
: t('请填写启动命令')
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<a-button type="default" style="height: auto" @click="openCmdAssistDialog">
|
|
||||||
{{ t("TXT_CODE_2728d0d4") }}
|
|
||||||
</a-button>
|
|
||||||
</a-input-group>
|
</a-input-group>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
@ -466,7 +464,7 @@ defineExpose({
|
|||||||
</div>
|
</div>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col v-if="options.imageSelectMethod === 'SELECT'" :xs="24" :lg="8" :offset="0">
|
<a-col v-if="options.imageSelectMethod === 'SELECT'" :xs="24" :lg="16" :offset="0">
|
||||||
<a-form-item :name="['docker', 'image']">
|
<a-form-item :name="['docker', 'image']">
|
||||||
<a-typography-title :level="5" :class="{ 'require-field': isDocker }">
|
<a-typography-title :level="5" :class="{ 'require-field': isDocker }">
|
||||||
{{ t("TXT_CODE_6904cb3") }}
|
{{ t("TXT_CODE_6904cb3") }}
|
||||||
@ -508,30 +506,16 @@ defineExpose({
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
|
||||||
<a-col :xs="24" :lg="8" :offset="0">
|
|
||||||
<a-form-item>
|
|
||||||
<a-typography-title :level="5">{{ t("TXT_CODE_c3a3b6b1") }}</a-typography-title>
|
|
||||||
<a-typography-paragraph>
|
|
||||||
<a-typography-text type="secondary" :class="!isPhone && 'two-line-height'">
|
|
||||||
{{ t("TXT_CODE_d1c78fbf") }}
|
|
||||||
</a-typography-text>
|
|
||||||
</a-typography-paragraph>
|
|
||||||
<a-tooltip placement="bottom">
|
|
||||||
<template #title>{{ t("TXT_CODE_8d4882b0") }}</template>
|
|
||||||
<a-input
|
|
||||||
v-model:value="options.config.docker.containerName"
|
|
||||||
:placeholder="t('TXT_CODE_f6047384')"
|
|
||||||
/>
|
|
||||||
</a-tooltip>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
|
|
||||||
<a-col :xs="24" :lg="16" :offset="0">
|
<a-col :xs="24" :lg="16" :offset="0">
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<a-typography-title :level="5">{{ t("TXT_CODE_9c247f6") }}</a-typography-title>
|
<a-typography-title :level="5">{{ t("挂载文件管理中的文件") }}</a-typography-title>
|
||||||
<a-typography-paragraph>
|
<a-typography-paragraph>
|
||||||
<a-typography-text type="secondary">
|
<a-typography-text type="secondary" :class="!isPhone && 'two-line-height'">
|
||||||
{{ t("TXT_CODE_df3fdec") }}
|
{{
|
||||||
|
t(
|
||||||
|
"填写一个容器内的文件路径,设置后,文件管理中的所有文件将挂载到填写的路径中。"
|
||||||
|
)
|
||||||
|
}}
|
||||||
</a-typography-text>
|
</a-typography-text>
|
||||||
</a-typography-paragraph>
|
</a-typography-paragraph>
|
||||||
<a-input
|
<a-input
|
||||||
@ -541,6 +525,28 @@ defineExpose({
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :xs="24" :lg="8" :offset="0">
|
||||||
|
<a-form-item name="changeWorkdir">
|
||||||
|
<a-typography-title :level="5" :class="{ 'require-field': isDocker }">
|
||||||
|
{{ t("自动切换工作路径") }}
|
||||||
|
</a-typography-title>
|
||||||
|
<a-typography-paragraph>
|
||||||
|
<a-typography-text type="secondary" :class="!isPhone && 'two-line-height'">
|
||||||
|
{{ t("启动容器时,自动将当前目录切换到工作目录,某些情况下可能需要这类功能") }}
|
||||||
|
</a-typography-text>
|
||||||
|
</a-typography-paragraph>
|
||||||
|
<a-switch
|
||||||
|
v-model:checked="options.config.docker.changeWorkdir"
|
||||||
|
:disabled="isGlobalTerminal"
|
||||||
|
checked-value="docker"
|
||||||
|
un-checked-value="general"
|
||||||
|
>
|
||||||
|
<template #checkedChildren><check-outlined /></template>
|
||||||
|
<template #unCheckedChildren><close-outlined /></template>
|
||||||
|
</a-switch>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
<a-col :xs="24" :lg="8" :offset="0">
|
<a-col :xs="24" :lg="8" :offset="0">
|
||||||
<a-form-item :name="['docker', 'networkMode']">
|
<a-form-item :name="['docker', 'networkMode']">
|
||||||
<a-typography-title :level="5" :class="{ 'require-field': isDocker }">
|
<a-typography-title :level="5" :class="{ 'require-field': isDocker }">
|
||||||
@ -681,6 +687,24 @@ defineExpose({
|
|||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :xs="24" :lg="8" :offset="0">
|
||||||
|
<a-form-item>
|
||||||
|
<a-typography-title :level="5">{{ t("TXT_CODE_c3a3b6b1") }}</a-typography-title>
|
||||||
|
<a-typography-paragraph>
|
||||||
|
<a-typography-text type="secondary">
|
||||||
|
{{ t("TXT_CODE_d1c78fbf") }}
|
||||||
|
</a-typography-text>
|
||||||
|
</a-typography-paragraph>
|
||||||
|
<a-tooltip placement="bottom">
|
||||||
|
<template #title>{{ t("TXT_CODE_8d4882b0") }}</template>
|
||||||
|
<a-input
|
||||||
|
v-model:value="options.config.docker.containerName"
|
||||||
|
:placeholder="t('TXT_CODE_f6047384')"
|
||||||
|
/>
|
||||||
|
</a-tooltip>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
</a-form>
|
</a-form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user