You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
882 B
36 lines
882 B
2 years ago
|
import path from "path";
|
||
2 years ago
|
import { readFileSync } from "fs";
|
||
2 years ago
|
|
||
|
import yaml from "js-yaml";
|
||
|
|
||
2 years ago
|
import checkAndCopyConfig from "utils/config/config";
|
||
2 years ago
|
|
||
2 years ago
|
export default function getDockerArguments(server) {
|
||
2 years ago
|
checkAndCopyConfig("docker.yaml");
|
||
|
|
||
|
const configFile = path.join(process.cwd(), "config", "docker.yaml");
|
||
2 years ago
|
const configData = readFileSync(configFile, "utf8");
|
||
2 years ago
|
const servers = yaml.load(configData);
|
||
|
|
||
|
if (!server) {
|
||
|
if (process.platform !== "win32" && process.platform !== "darwin") {
|
||
|
return { socketPath: "/var/run/docker.sock" };
|
||
|
}
|
||
2 years ago
|
|
||
|
return { host: "127.0.0.1" };
|
||
|
}
|
||
|
|
||
|
if (servers[server]) {
|
||
2 years ago
|
if (servers[server].socket) {
|
||
|
return { socketPath: servers[server].socket };
|
||
2 years ago
|
}
|
||
|
|
||
|
if (servers[server].host) {
|
||
2 years ago
|
return { host: servers[server].host, port: servers[server].port || null };
|
||
|
}
|
||
2 years ago
|
|
||
|
return servers[server];
|
||
2 years ago
|
}
|
||
2 years ago
|
return null;
|
||
2 years ago
|
}
|