diff options
author | Yehonal <yehonal.azeroth@gmail.com> | 2021-05-04 11:35:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-04 11:35:24 +0200 |
commit | f6c6123d85d467134ee24565c9d98efdfc3a0c41 (patch) | |
tree | 2b70863b40601c5f98d2fbe9e8aa51fa150e7ceb /apps/docker/docker-cmd.ts | |
parent | a1b0c4541762320867aa7e7150c942224c18753d (diff) |
feat(docker): production images, integrated ccache and many other improvements (#5551)
Diffstat (limited to 'apps/docker/docker-cmd.ts')
-rw-r--r-- | apps/docker/docker-cmd.ts | 94 |
1 files changed, 71 insertions, 23 deletions
diff --git a/apps/docker/docker-cmd.ts b/apps/docker/docker-cmd.ts index 8fdd94e886..512f1eb00c 100644 --- a/apps/docker/docker-cmd.ts +++ b/apps/docker/docker-cmd.ts @@ -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", -]); + "docker-compose run --rm ac-build bash apps/docker/docker-build-dev.sh", +], env); shellCommandFactory( - "build:clean", - "Clean and run build", + "build:nocache", + "Build the authserver and worldserver without docker cache", [ - "docker-compose --profile all build", + "docker-compose --profile local build --no-cache --parallel", "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", + "build:compile", + "Run the compilation process only, without rebuilding all docker images and importing db", [ - "docker-compose --profile all build --no-cache", + "docker-compose build --parallel ac-build", "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 0", ], + env, ); shellCommandFactory( - "build:compile", - "Run the compilation process only, without rebuilding all docker images and importing db", + "clean:build", + "Clean build files", [ - "docker-compose build ac-build", "docker image prune -f", - "docker-compose run --rm ac-build bash acore.sh compiler build", + `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(); |