mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
feat(docker): production images, integrated ccache and many other improvements (#5551)
This commit is contained in:
@@ -7,6 +7,12 @@ import {
|
||||
|
||||
const program = new Command();
|
||||
|
||||
const env = {
|
||||
COMPOSE_DOCKER_CLI_BUILD: "1",
|
||||
DOCKER_BUILDKIT: "1",
|
||||
BUILDKIT_INLINE_CACHE: "1",
|
||||
};
|
||||
|
||||
program
|
||||
.name("acore.sh docker")
|
||||
.description("Shell scripts for docker")
|
||||
@@ -16,85 +22,125 @@ shellCommandFactory(
|
||||
"start:app",
|
||||
"Startup the authserver and worldserver apps",
|
||||
["docker-compose --profile app up"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"start:app:d",
|
||||
"Startup the authserver and worldserver apps in detached mode",
|
||||
["docker-compose --profile app up -d"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory("build", "Build the authserver and worldserver", [
|
||||
"docker-compose --profile all build",
|
||||
"docker-compose --profile local build --parallel",
|
||||
"docker image prune -f",
|
||||
"docker-compose run --rm ac-build bash bin/acore-docker-update",
|
||||
]);
|
||||
|
||||
shellCommandFactory(
|
||||
"build:clean",
|
||||
"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",
|
||||
],
|
||||
);
|
||||
"docker-compose run --rm ac-build bash apps/docker/docker-build-dev.sh",
|
||||
], env);
|
||||
|
||||
shellCommandFactory(
|
||||
"build:nocache",
|
||||
"Build the authserver and worldserver without docker cache",
|
||||
[
|
||||
"docker-compose --profile all build --no-cache",
|
||||
"docker-compose --profile local build --no-cache --parallel",
|
||||
"docker image prune -f",
|
||||
"docker-compose run --rm ac-build bash bin/acore-docker-update",
|
||||
"docker-compose run --rm ac-build bash apps/docker/docker-build-dev.sh",
|
||||
],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"build:compile",
|
||||
"Run the compilation process only, without rebuilding all docker images and importing db",
|
||||
[
|
||||
"docker-compose build ac-build",
|
||||
"docker-compose build --parallel ac-build",
|
||||
"docker image prune -f",
|
||||
"docker-compose run --rm ac-build bash acore.sh compiler build",
|
||||
"docker-compose run --rm ac-build bash apps/docker/docker-build-dev.sh 0",
|
||||
],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"clean:build",
|
||||
"Clean build files",
|
||||
[
|
||||
"docker image prune -f",
|
||||
`docker-compose run --rm ac-build bash acore.sh compiler clean`,
|
||||
],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"client-data",
|
||||
"Download client data inside the ac-data volume",
|
||||
["docker-compose run --rm ac-worldserver bash acore.sh client-data"],
|
||||
["docker-compose run --rm ac-build bash acore.sh client-data"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"db-import",
|
||||
"Create and upgrade the database with latest updates",
|
||||
["docker-compose run --rm ac-build bash acore.sh db-assembler import-all"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"dev:up",
|
||||
"Start the dev server container",
|
||||
["docker-compose up ac-dev-server"],
|
||||
"Start the dev server container in background",
|
||||
["docker-compose up -d ac-dev-server"],
|
||||
env,
|
||||
);
|
||||
|
||||
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"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"dev:dash [args...]",
|
||||
"Execute acore dashboard within a running ac-dev-server",
|
||||
["docker-compose run --rm ac-dev-server bash acore.sh"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"dev:shell [args...]",
|
||||
"Open an interactive shell within the dev server",
|
||||
["docker-compose run --rm ac-dev-server bash"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"prod:build",
|
||||
"Build producion services",
|
||||
[
|
||||
"docker-compose --profile prod build --parallel",
|
||||
"docker image prune -f",
|
||||
],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"prod:pull",
|
||||
"Pull production services from the remote registry",
|
||||
["docker-compose --profile prod pull"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"prod:up",
|
||||
"Start production services (foreground)",
|
||||
["docker-compose --profile prod-app up"],
|
||||
env,
|
||||
);
|
||||
|
||||
shellCommandFactory(
|
||||
"prod:up:d",
|
||||
"Start production services (background)",
|
||||
["docker-compose --profile prod-app up -d"],
|
||||
env,
|
||||
);
|
||||
|
||||
program
|
||||
@@ -125,7 +171,7 @@ program
|
||||
|
||||
if (!services) {
|
||||
console.error("No services available!");
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
services.pop();
|
||||
@@ -144,8 +190,8 @@ program
|
||||
}
|
||||
|
||||
if (!selService) {
|
||||
console.log(`Service ${service} is not available`)
|
||||
return;
|
||||
console.log(`Service ${service} is not available`);
|
||||
return;
|
||||
}
|
||||
|
||||
command = `docker attach ${selService.split(" ")[0]}`;
|
||||
@@ -185,7 +231,7 @@ while (true) {
|
||||
const command = await Input.prompt({
|
||||
message: "Enter the command:",
|
||||
});
|
||||
console.log(command)
|
||||
console.log(command);
|
||||
await program.parseAsync(command.split(" "));
|
||||
} else {
|
||||
await program.parseAsync(Deno.args);
|
||||
@@ -204,6 +250,7 @@ function shellCommandFactory(
|
||||
name: string,
|
||||
description: string,
|
||||
commands: string[],
|
||||
env?: { [key: string]: string },
|
||||
): Command {
|
||||
return program
|
||||
.command(name)
|
||||
@@ -231,6 +278,7 @@ function shellCommandFactory(
|
||||
const shellCmd = run({
|
||||
cmd,
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, ...env },
|
||||
});
|
||||
|
||||
const status = await shellCmd.status();
|
||||
|
||||
Reference in New Issue
Block a user