mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-02-11 15:49:53 +08:00
Feat: docker workingDir
This commit is contained in:
parent
7f8128f994
commit
6b0f0ea57e
1
common/global.d.ts
vendored
1
common/global.d.ts
vendored
@ -71,6 +71,7 @@ export interface IGlobalInstanceDockerConfig {
|
||||
networkAliases?: string[];
|
||||
cpusetCpus?: string;
|
||||
cpuUsage?: number;
|
||||
workingDir?: string;
|
||||
}
|
||||
|
||||
export interface IPanelResponseProtocol {
|
||||
|
@ -137,23 +137,12 @@ export default class DockerStartCommand extends InstanceCommand {
|
||||
// resolve extra path mounts
|
||||
const extraVolumes = instance.config.docker.extraVolumes;
|
||||
const extraBinds = [];
|
||||
for (const it of extraVolumes) {
|
||||
if (!it) continue;
|
||||
const element = it.split(":");
|
||||
if (element.length < 2) continue;
|
||||
let hostPath = element[0];
|
||||
let containerPath = element.slice(1).join(":");
|
||||
|
||||
if (path.isAbsolute(containerPath)) {
|
||||
containerPath = path.normalize(containerPath);
|
||||
} else {
|
||||
containerPath = path.normalize(path.join("/workspace/", containerPath));
|
||||
}
|
||||
if (path.isAbsolute(hostPath)) {
|
||||
hostPath = path.normalize(hostPath);
|
||||
} else {
|
||||
hostPath = path.normalize(path.join(process.cwd(), hostPath));
|
||||
}
|
||||
for (const item of extraVolumes) {
|
||||
if (!item) continue;
|
||||
const paths = item.split(":");
|
||||
if (paths.length < 2) continue;
|
||||
const hostPath = path.normalize(paths[0]);
|
||||
const containerPath = path.normalize(paths.slice(1).join(":"));
|
||||
extraBinds.push(`${hostPath}:${containerPath}`);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Instance from "./instance";
|
||||
import { IDockerConfig } from "./interface";
|
||||
import os from "os";
|
||||
import { IGlobalInstanceConfig } from "../../../../common/global";
|
||||
import { IGlobalInstanceConfig, IGlobalInstanceDockerConfig } from "common/global";
|
||||
interface IActionCommand {
|
||||
name: string;
|
||||
command: string;
|
||||
@ -52,7 +51,7 @@ export default class InstanceConfig implements IGlobalInstanceConfig {
|
||||
};
|
||||
|
||||
// Extend
|
||||
public docker: IDockerConfig = {
|
||||
public docker: IGlobalInstanceDockerConfig = {
|
||||
containerName: "",
|
||||
image: "",
|
||||
ports: [],
|
||||
|
@ -1,22 +1,5 @@
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
// interface of docker config
|
||||
export interface IDockerConfig {
|
||||
containerName: string;
|
||||
image: string;
|
||||
memory: number; // Memory limit in bytes.
|
||||
ports: string[];
|
||||
extraVolumes: string[];
|
||||
maxSpace: number;
|
||||
network: number;
|
||||
io: number;
|
||||
networkMode: string;
|
||||
networkAliases: string[];
|
||||
cpusetCpus: string; // CPU allowed to execute (eg 0-3, , 0, 1)
|
||||
cpuUsage: number;
|
||||
workingDir: string;
|
||||
}
|
||||
|
||||
// Instance specific process interface
|
||||
export interface IInstanceProcess extends EventEmitter {
|
||||
pid?: number | string;
|
||||
|
@ -394,6 +394,21 @@ defineExpose({
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :lg="16" :offset="0">
|
||||
<a-form-item>
|
||||
<a-typography-title :level="5">{{ t("容器工作目录挂载") }}</a-typography-title>
|
||||
<a-typography-paragraph>
|
||||
<a-typography-text type="secondary">
|
||||
{{
|
||||
t(
|
||||
"实例工作目录中的所有文件将会挂载到容器内部的此目录中,不填写则默认 /workspace/"
|
||||
)
|
||||
}}
|
||||
</a-typography-text>
|
||||
</a-typography-paragraph>
|
||||
<a-input v-model:value="options.config.docker.workingDir" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :lg="8" :offset="0">
|
||||
<a-form-item>
|
||||
<a-typography-title :level="5">{{ t("TXT_CODE_cf88c936") }}</a-typography-title>
|
||||
|
@ -1207,7 +1207,7 @@
|
||||
"TXT_CODE_9278b7b0": "If engaged in commercial activities, consider using container to protect the host.",
|
||||
"TXT_CODE_5be6c38e": "Default Type",
|
||||
"TXT_CODE_6c87dd18": "Virtualization Container (Linux Docker)",
|
||||
"TXT_CODE_6904cb3": "Environment Image",
|
||||
"TXT_CODE_6904cb3": "Docker Image",
|
||||
"TXT_CODE_a584cb71": "Specify the instance image.",
|
||||
"TXT_CODE_cf88c936": "Open Ports",
|
||||
"TXT_CODE_3e68ca00": "Additional Mount points",
|
||||
|
@ -1208,7 +1208,7 @@
|
||||
"TXT_CODE_9278b7b0": "通常默认即可,如果从事商业活动则应当使用虚拟化容器启动方式,否则主机将可能被入侵。",
|
||||
"TXT_CODE_5be6c38e": "默认类型",
|
||||
"TXT_CODE_6c87dd18": "虚拟化容器(Linux Docker)",
|
||||
"TXT_CODE_6904cb3": "环境镜像",
|
||||
"TXT_CODE_6904cb3": "Docker 镜像",
|
||||
"TXT_CODE_a584cb71": "指定实例镜像",
|
||||
"TXT_CODE_cf88c936": "开放端口",
|
||||
"TXT_CODE_3e68ca00": "额外挂载路径",
|
||||
|
Loading…
Reference in New Issue
Block a user