mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
feat(CORE/docker): switch to docker compose and check the version (#13444)
* feat(docker): switch to `docker compose` and check the version * chore: removed all docker-compose commands in CI
This commit is contained in:
8
.github/workflows/docker_build.yml
vendored
8
.github/workflows/docker_build.yml
vendored
@@ -38,7 +38,7 @@ jobs:
|
|||||||
sudo rm -rf /opt/ghc
|
sudo rm -rf /opt/ghc
|
||||||
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
||||||
docker --version
|
docker --version
|
||||||
docker-compose --version
|
docker compose --version
|
||||||
|
|
||||||
# TODO: make it work
|
# TODO: make it work
|
||||||
# - uses: whoan/docker-build-with-cache-action@v5
|
# - uses: whoan/docker-build-with-cache-action@v5
|
||||||
@@ -75,7 +75,7 @@ jobs:
|
|||||||
# DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
|
# DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
|
||||||
if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
|
if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
|
||||||
run: |
|
run: |
|
||||||
docker-compose --profile dev --profile local push
|
docker compose --profile dev --profile local push
|
||||||
|
|
||||||
- name: Cache
|
- name: Cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
@@ -98,7 +98,7 @@ jobs:
|
|||||||
export DOCKER_USER_ID=$(id -u)
|
export DOCKER_USER_ID=$(id -u)
|
||||||
export DOCKER_GROUP_ID=$(id -u)
|
export DOCKER_GROUP_ID=$(id -u)
|
||||||
./acore.sh docker prod:build
|
./acore.sh docker prod:build
|
||||||
docker-compose run --no-deps --name build ac-build echo "image created"
|
docker compose run --no-deps --name build ac-build echo "image created"
|
||||||
docker cp build:/azerothcore/var/ccache var/docker/
|
docker cp build:/azerothcore/var/ccache var/docker/
|
||||||
echo "ccache exported"
|
echo "ccache exported"
|
||||||
|
|
||||||
@@ -107,4 +107,4 @@ jobs:
|
|||||||
# DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
|
# DOCKER_IMAGE_TAG: ${{ steps.extract_branch.outputs.branch }}
|
||||||
if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
|
if: github.repository == 'azerothcore/azerothcore-wotlk' && steps.extract_branch.outputs.branch == 'master'
|
||||||
run: |
|
run: |
|
||||||
docker-compose --profile prod push
|
docker compose --profile prod push
|
||||||
|
|||||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -36,7 +36,7 @@
|
|||||||
"externalConsole": true,
|
"externalConsole": true,
|
||||||
"pipeTransport": {
|
"pipeTransport": {
|
||||||
"debuggerPath": "/usr/bin/gdb",
|
"debuggerPath": "/usr/bin/gdb",
|
||||||
"pipeProgram": "docker-compose",
|
"pipeProgram": "docker compose",
|
||||||
"pipeArgs": [
|
"pipeArgs": [
|
||||||
"exec", "-T", "ac-worldserver", "sh", "-c"
|
"exec", "-T", "ac-worldserver", "sh", "-c"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
Select,
|
Select,
|
||||||
} from "https://deno.land/x/cliffy@v0.25.2/prompt/mod.ts";
|
} from "https://deno.land/x/cliffy@v0.25.2/prompt/mod.ts";
|
||||||
|
import * as semver from "https://deno.land/std@0.159.0/semver/mod.ts";
|
||||||
|
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
|
|
||||||
@@ -13,6 +14,8 @@ const env = {
|
|||||||
BUILDKIT_INLINE_CACHE: "1",
|
BUILDKIT_INLINE_CACHE: "1",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const MIN_COMPOSE_VERSION = "2.0.0";
|
||||||
|
|
||||||
program
|
program
|
||||||
.name("acore.sh docker")
|
.name("acore.sh docker")
|
||||||
.description("Shell scripts for docker")
|
.description("Shell scripts for docker")
|
||||||
@@ -21,43 +24,48 @@ program
|
|||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"start:app",
|
"start:app",
|
||||||
"Startup the authserver and worldserver apps",
|
"Startup the authserver and worldserver apps",
|
||||||
["docker-compose --profile app up"],
|
["docker compose --profile app up"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"start:app:d",
|
"start:app:d",
|
||||||
"Startup the authserver and worldserver apps in detached mode",
|
"Startup the authserver and worldserver apps in detached mode",
|
||||||
["docker-compose --profile app up -d"],
|
["docker compose --profile app up -d"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory("build", "Build the authserver and worldserver", [
|
shellCommandFactory(
|
||||||
"docker-compose --profile local build --parallel",
|
"build",
|
||||||
"docker image prune -f",
|
"Build the authserver and worldserver",
|
||||||
"docker-compose run --rm ac-build bash apps/docker/docker-build-dev.sh",
|
[
|
||||||
], env);
|
"docker compose --profile local build --parallel",
|
||||||
|
"docker image prune -f",
|
||||||
|
"docker compose run --rm ac-build bash apps/docker/docker-build-dev.sh",
|
||||||
|
],
|
||||||
|
env
|
||||||
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"build:nocache",
|
"build:nocache",
|
||||||
"Build the authserver and worldserver without docker cache",
|
"Build the authserver and worldserver without docker cache",
|
||||||
[
|
[
|
||||||
"docker-compose --profile local build --no-cache --parallel",
|
"docker compose --profile local build --no-cache --parallel",
|
||||||
"docker image prune -f",
|
"docker image prune -f",
|
||||||
"docker-compose run --rm ac-build bash apps/docker/docker-build-dev.sh",
|
"docker compose run --rm ac-build bash apps/docker/docker-build-dev.sh",
|
||||||
],
|
],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"build:compile",
|
"build:compile",
|
||||||
"Run the compilation process only, without rebuilding all docker images",
|
"Run the compilation process only, without rebuilding all docker images",
|
||||||
[
|
[
|
||||||
"docker-compose build --parallel ac-build",
|
"docker compose build --parallel ac-build",
|
||||||
"docker image prune -f",
|
"docker image prune -f",
|
||||||
"docker-compose run --rm ac-build bash apps/docker/docker-build-dev.sh",
|
"docker compose run --rm ac-build bash apps/docker/docker-build-dev.sh",
|
||||||
],
|
],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
@@ -65,78 +73,75 @@ shellCommandFactory(
|
|||||||
"Clean build files",
|
"Clean build files",
|
||||||
[
|
[
|
||||||
"docker image prune -f",
|
"docker image prune -f",
|
||||||
`docker-compose run --rm ac-build bash acore.sh compiler clean`,
|
`docker compose run --rm ac-build bash acore.sh compiler clean`,
|
||||||
],
|
],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"client-data",
|
"client-data",
|
||||||
"Download client data inside the ac-data volume",
|
"Download client data inside the ac-data volume",
|
||||||
["docker-compose run --rm ac-build bash acore.sh client-data"],
|
["docker compose run --rm ac-build bash acore.sh client-data"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"dev:up",
|
"dev:up",
|
||||||
"Start the dev server container in background",
|
"Start the dev server container in background",
|
||||||
["docker-compose up -d ac-dev-server"],
|
["docker compose up -d ac-dev-server"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"dev:build",
|
"dev:build",
|
||||||
"Build using the dev server, it uses volumes to compile which can be faster on linux & WSL",
|
"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"],
|
["docker compose run --rm ac-dev-server bash acore.sh compiler build"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"dev:dash [args...]",
|
"dev:dash [args...]",
|
||||||
"Execute acore dashboard within a running ac-dev-server",
|
"Execute acore dashboard within a running ac-dev-server",
|
||||||
["docker-compose run --rm ac-dev-server bash acore.sh"],
|
["docker compose run --rm ac-dev-server bash acore.sh"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"dev:shell [args...]",
|
"dev:shell [args...]",
|
||||||
"Open an interactive shell within the dev server",
|
"Open an interactive shell within the dev server",
|
||||||
[
|
[
|
||||||
"docker-compose up -d ac-dev-server",
|
"docker compose up -d ac-dev-server",
|
||||||
"docker-compose exec ac-dev-server bash",
|
"docker compose exec ac-dev-server bash",
|
||||||
],
|
],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"prod:build",
|
"prod:build",
|
||||||
"Build producion services",
|
"Build producion services",
|
||||||
[
|
["docker compose --profile prod build --parallel", "docker image prune -f"],
|
||||||
"docker-compose --profile prod build --parallel",
|
env
|
||||||
"docker image prune -f",
|
|
||||||
],
|
|
||||||
env,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"prod:pull",
|
"prod:pull",
|
||||||
"Pull production services from the remote registry",
|
"Pull production services from the remote registry",
|
||||||
["docker-compose --profile prod pull"],
|
["docker compose --profile prod pull"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"prod:up",
|
"prod:up",
|
||||||
"Start production services (foreground)",
|
"Start production services (foreground)",
|
||||||
["docker-compose --profile prod-app up"],
|
["docker compose --profile prod-app up"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
shellCommandFactory(
|
shellCommandFactory(
|
||||||
"prod:up:d",
|
"prod:up:d",
|
||||||
"Start production services (background)",
|
"Start production services (background)",
|
||||||
["docker-compose --profile prod-app up -d"],
|
["docker compose --profile prod-app up -d"],
|
||||||
env,
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
program
|
program
|
||||||
@@ -145,7 +150,7 @@ program
|
|||||||
.action(async (service: string | undefined) => {
|
.action(async (service: string | undefined) => {
|
||||||
const { run } = Deno;
|
const { run } = Deno;
|
||||||
|
|
||||||
let command = `docker-compose ps`;
|
let command = `docker compose ps`;
|
||||||
|
|
||||||
if (service) {
|
if (service) {
|
||||||
command = `${command} ${service}`;
|
command = `${command} ${service}`;
|
||||||
@@ -196,8 +201,8 @@ program
|
|||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
ink.colorize(
|
ink.colorize(
|
||||||
"<yellow>NOTE: you can detach from a container and leave it running using the CTRL-p CTRL-q key sequence.</yellow>",
|
"<yellow>NOTE: you can detach from a container and leave it running using the CTRL-p CTRL-q key sequence.</yellow>"
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
cmd = command.split(" ");
|
cmd = command.split(" ");
|
||||||
@@ -219,22 +224,6 @@ program
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle it however you like
|
|
||||||
// e.g. display usage
|
|
||||||
while (true) {
|
|
||||||
if (Deno.args.length === 0) {
|
|
||||||
program.outputHelp();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
@@ -246,24 +235,20 @@ function shellCommandFactory(
|
|||||||
name: string,
|
name: string,
|
||||||
description: string,
|
description: string,
|
||||||
commands: string[],
|
commands: string[],
|
||||||
env?: { [key: string]: string },
|
env?: { [key: string]: string }
|
||||||
): Command {
|
): Command {
|
||||||
return program
|
return program
|
||||||
.command(name)
|
.command(name)
|
||||||
.description(
|
.description(
|
||||||
`${description}. Command: \n"${
|
`${description}. Command: \n"${ink.colorize(
|
||||||
ink.colorize(
|
`<green>${commands.join(" && ")}</green>`
|
||||||
`<green>${commands.join(" && ")}</green>`,
|
)}"\n`
|
||||||
)
|
|
||||||
}"\n`,
|
|
||||||
)
|
)
|
||||||
.action(async (args: string[] | undefined) => {
|
.action(async (args: string[] | undefined) => {
|
||||||
const { run } = Deno;
|
const { run } = Deno;
|
||||||
|
|
||||||
for (const command of commands) {
|
for (const command of commands) {
|
||||||
console.log(
|
console.log(ink.colorize(`<green>>>>>> Running: ${command}</green>`));
|
||||||
ink.colorize(`<green>>>>>> Running: ${command}</green>`),
|
|
||||||
);
|
|
||||||
|
|
||||||
const cmd = command.split(" ");
|
const cmd = command.split(" ");
|
||||||
|
|
||||||
@@ -281,11 +266,67 @@ function shellCommandFactory(
|
|||||||
|
|
||||||
if (!status.success) {
|
if (!status.success) {
|
||||||
throw new Error(`Failed with error: ${status.code}, however,
|
throw new Error(`Failed with error: ${status.code}, however,
|
||||||
it's not related to this Deno script directly. An error occurred within
|
it's not related to this Deno script directly. An error occurred within
|
||||||
the script called by the command itself`);
|
the script called by the command itself`);
|
||||||
}
|
}
|
||||||
|
|
||||||
shellCmd.close();
|
shellCmd.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkDockerVersion() {
|
||||||
|
const { run } = Deno;
|
||||||
|
const dockerVerCmd = run({
|
||||||
|
cmd: ["docker", "compose", "version"],
|
||||||
|
cwd: process.cwd(),
|
||||||
|
env: { ...process.env, ...env },
|
||||||
|
stdout: "piped",
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = await dockerVerCmd.output();
|
||||||
|
const status = await dockerVerCmd.status();
|
||||||
|
const outStr = new TextDecoder().decode(output);
|
||||||
|
|
||||||
|
if (!status.success) {
|
||||||
|
return 'not installed?'
|
||||||
|
}
|
||||||
|
|
||||||
|
const version = outStr.split(" ").pop()?.trim();
|
||||||
|
|
||||||
|
if (!version) return version;
|
||||||
|
|
||||||
|
if (!semver.gte(version, MIN_COMPOSE_VERSION)) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
// Handle it however you like
|
||||||
|
// e.g. display usage
|
||||||
|
while (true) {
|
||||||
|
const version = await checkDockerVersion();
|
||||||
|
if (version !== true) {
|
||||||
|
console.error(
|
||||||
|
ink.colorize(`<red>ERROR: Your docker compose version (${version}) must be higher or equal to ${MIN_COMPOSE_VERSION}. Please install the new version of docker compose and try again</red>`)
|
||||||
|
);
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Deno.args.length === 0) {
|
||||||
|
program.outputHelp();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
|||||||
2
conf/dist/env.docker
vendored
2
conf/dist/env.docker
vendored
@@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Create a .env file in the root folder and use the following
|
# Create a .env file in the root folder and use the following
|
||||||
# variables to configure your docker-compose
|
# variables to configure your docker compose
|
||||||
#
|
#
|
||||||
|
|
||||||
DOCKER_AC_ENV_FILE=
|
DOCKER_AC_ENV_FILE=
|
||||||
|
|||||||
Reference in New Issue
Block a user