mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
fix(Docker): windows improvements and permissions fix (#5444)
This commit is contained in:
@@ -7,59 +7,98 @@ import {
|
||||
|
||||
const program = new Command();
|
||||
|
||||
program.name("acore.sh docker")
|
||||
program
|
||||
.name("acore.sh docker")
|
||||
.description("Shell scripts for docker")
|
||||
.version("1.0.0");
|
||||
|
||||
shellCommandFactory(
|
||||
"start:app",
|
||||
"Startup the authserver and worldserver apps",
|
||||
"docker-compose --profile app up",
|
||||
["docker-compose --profile app up"],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"start:app:d",
|
||||
"Startup the authserver and worldserver apps in detached mode",
|
||||
"docker-compose --profile app up -d",
|
||||
["docker-compose --profile app up -d"],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"start:dev",
|
||||
"Startup the dev server",
|
||||
"docker-compose --profile dev up",
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"build",
|
||||
"Build the authserver and worldserver",
|
||||
`docker-compose run --rm ac-dev-server bash bin/acore-docker-build`,
|
||||
);
|
||||
shellCommandFactory("build", "Build the authserver and worldserver", [
|
||||
"docker-compose --profile all build",
|
||||
"docker image prune -f",
|
||||
"docker-compose run --rm ac-build bash bin/acore-docker-update",
|
||||
]);
|
||||
|
||||
shellCommandFactory(
|
||||
"build:clean",
|
||||
"Clean build data",
|
||||
`docker-compose run --rm ac-dev-server bash rm -rf var/build`,
|
||||
"Clean and run build",
|
||||
[
|
||||
"docker-compose --profile all build",
|
||||
"docker image prune -f",
|
||||
`docker-compose run --rm ac-build bash acore.sh compiler clean`,
|
||||
"docker-compose run --rm ac-build bash bin/acore-docker-update",
|
||||
],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"build:nocache",
|
||||
"Build the authserver and worldserver without docker cache",
|
||||
[
|
||||
"docker-compose --profile all build --no-cache",
|
||||
"docker image prune -f",
|
||||
"docker-compose run --rm ac-build bash bin/acore-docker-update",
|
||||
],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"build:compile",
|
||||
"Run the compilation process only, without rebuilding all docker images and importing db",
|
||||
[
|
||||
"docker-compose build ac-build",
|
||||
"docker image prune -f",
|
||||
"docker-compose run --rm ac-build bash acore.sh compiler build",
|
||||
],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"client-data",
|
||||
"Download client data inside the ac-data volume",
|
||||
"docker-compose run --rm ac-dev-server bash acore.sh client-data",
|
||||
["docker-compose run --rm ac-worldserver bash acore.sh client-data"],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"db-import",
|
||||
"Create and upgrade the database with latest updates",
|
||||
"docker-compose run --rm ac-dev-server bash acore.sh db-assembler import-all",
|
||||
["docker-compose run --rm ac-build bash acore.sh db-assembler import-all"],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"dashboard [args...]",
|
||||
"Execute acore dashboard within a running ac-dev-server",
|
||||
"docker-compose exec ac-dev-server bash acore.sh",
|
||||
"dev:up",
|
||||
"Start the dev server container",
|
||||
["docker-compose up ac-dev-server"],
|
||||
);
|
||||
|
||||
program.command("attach [service]")
|
||||
shellCommandFactory(
|
||||
"dev:build",
|
||||
"Build using the dev server, it uses volumes to compile which can be faster on linux & WSL",
|
||||
["docker-compose run --rm ac-dev-server bash acore.sh compiler build"],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"dev:dash [args...]",
|
||||
"Execute acore dashboard within a running ac-dev-server",
|
||||
["docker-compose run --rm ac-dev-server bash acore.sh"],
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"dev:shell [args...]",
|
||||
"Open an interactive shell within the dev server",
|
||||
["docker-compose run --rm ac-dev-server bash"],
|
||||
);
|
||||
|
||||
program
|
||||
.command("attach [service]")
|
||||
.description("attach to a service")
|
||||
.action(async (service: string | undefined) => {
|
||||
const { run } = Deno;
|
||||
@@ -84,6 +123,11 @@ program.command("attach [service]")
|
||||
|
||||
let services = new TextDecoder().decode(output).split("\n");
|
||||
|
||||
if (!services) {
|
||||
console.error("No services available!");
|
||||
return
|
||||
}
|
||||
|
||||
services.pop();
|
||||
services = services.slice(2);
|
||||
|
||||
@@ -99,6 +143,11 @@ program.command("attach [service]")
|
||||
selService = services[0];
|
||||
}
|
||||
|
||||
if (!selService) {
|
||||
console.log(`Service ${service} is not available`)
|
||||
return;
|
||||
}
|
||||
|
||||
command = `docker attach ${selService.split(" ")[0]}`;
|
||||
|
||||
console.log(ink.colorize(`<green>>>>>> Running: ${command}</green>`));
|
||||
@@ -121,9 +170,12 @@ program.command("attach [service]")
|
||||
shellCmd.close();
|
||||
});
|
||||
|
||||
program.command("quit").description("Close docker command").action(()=> {
|
||||
process.exit(0)
|
||||
})
|
||||
program
|
||||
.command("quit")
|
||||
.description("Close docker command")
|
||||
.action(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
// Handle it however you like
|
||||
// e.g. display usage
|
||||
@@ -133,42 +185,63 @@ while (true) {
|
||||
const command = await Input.prompt({
|
||||
message: "Enter the command:",
|
||||
});
|
||||
console.log(command)
|
||||
await program.parseAsync(command.split(" "));
|
||||
} else {
|
||||
await program.parseAsync(Deno.args);
|
||||
process.exit(0)
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param description
|
||||
* @param commands you can pass one or more commands, they will be executed sequentially
|
||||
* @returns
|
||||
*/
|
||||
function shellCommandFactory(
|
||||
name: string,
|
||||
description: string,
|
||||
command: string,
|
||||
commands: string[],
|
||||
): Command {
|
||||
return program.command(name)
|
||||
return program
|
||||
.command(name)
|
||||
.description(
|
||||
`${description}. Command: \n"${ink.colorize(`<green>${command}</green>`)}"\n`,
|
||||
`${description}. Command: \n"${
|
||||
ink.colorize(
|
||||
`<green>${commands.join(" && ")}</green>`,
|
||||
)
|
||||
}"\n`,
|
||||
)
|
||||
.action(async (args: any[] | undefined) => {
|
||||
const { run } = Deno;
|
||||
|
||||
console.log(ink.colorize(`<green>>>>>> Running: ${command}</green>`));
|
||||
for (const command of commands) {
|
||||
console.log(
|
||||
ink.colorize(`<green>>>>>> Running: ${command}</green>`),
|
||||
);
|
||||
|
||||
const cmd = command.split(" ");
|
||||
const cmd = command.split(" ");
|
||||
|
||||
if (Array.isArray(args)) {
|
||||
cmd.push(...args);
|
||||
if (Array.isArray(args)) {
|
||||
cmd.push(...args);
|
||||
}
|
||||
|
||||
const shellCmd = run({
|
||||
cmd,
|
||||
cwd: process.cwd(),
|
||||
});
|
||||
|
||||
const status = await shellCmd.status();
|
||||
|
||||
if (!status.success) {
|
||||
throw new Error(`Failed with error: ${status.code}, however,
|
||||
it's not related to this Deno script directly. An error occurred within
|
||||
the script called by the command itself`);
|
||||
}
|
||||
|
||||
shellCmd.close();
|
||||
}
|
||||
|
||||
const shellCmd = run({
|
||||
cmd,
|
||||
cwd: process.cwd(),
|
||||
});
|
||||
|
||||
await shellCmd.status();
|
||||
|
||||
shellCmd.close();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user