From a85e349277c296ecbec58738ab241a55e23b4e78 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Sun, 8 Oct 2023 11:12:52 +0900 Subject: [PATCH] fix(wb): make 'docker build' refer to WB_ENV --- packages/wb/src/commands/test.ts | 4 ++-- packages/wb/src/scripts/dockerScripts.ts | 4 ++-- packages/wb/src/scripts/execution/baseExecutionScripts.ts | 6 +++--- packages/wb/src/scripts/execution/httpServerScripts.ts | 2 +- packages/wb/src/scripts/execution/plainAppScripts.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/wb/src/commands/test.ts b/packages/wb/src/commands/test.ts index a07b4950..1878ff40 100644 --- a/packages/wb/src/commands/test.ts +++ b/packages/wb/src/commands/test.ts @@ -82,7 +82,7 @@ export async function test(argv: ArgumentsCamelCase { - await runWithSpawn(`${scripts.buildDocker(argv, 'test')}`, argv); + await runWithSpawn(`${scripts.buildDocker()}`, argv); process.exitCode = await runWithSpawn( `${prefix}${scripts.testE2E(argv, { startCommand: dockerScripts.stopAndStart(true), diff --git a/packages/wb/src/scripts/dockerScripts.ts b/packages/wb/src/scripts/dockerScripts.ts index 82d3c98f..a8c164fd 100644 --- a/packages/wb/src/scripts/dockerScripts.ts +++ b/packages/wb/src/scripts/dockerScripts.ts @@ -8,7 +8,7 @@ import { spawnSyncOnExit } from '../utils.js'; * Note that `YARN zzz` is replaced with `yarn zzz` or `node_modules/.bin/zzz`. */ class DockerScripts { - buildDevImage(wbEnv = 'local'): string { + buildDevImage(): string { // e.g. coding-booster uses `"docker/build/prepare": "touch drill-users.csv",` const prefix = project.dockerPackageJson.scripts?.['docker/build/prepare'] ? 'yarn run docker/build/prepare && ' @@ -17,7 +17,7 @@ class DockerScripts { && ${prefix}YARN wb optimizeForDockerBuild --outside && YARN wb retry -- docker build -t ${project.nameWithoutNamespace} --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64) - --build-arg WB_ENV=${wbEnv} + --build-arg WB_ENV=${process.env.WB_ENV} --build-arg WB_VERSION=dev .`; } stopAndStart(unbuffer = false, additionalOptions = '', additionalArgs = ''): string { diff --git a/packages/wb/src/scripts/execution/baseExecutionScripts.ts b/packages/wb/src/scripts/execution/baseExecutionScripts.ts index cea5f785..ce99cb25 100644 --- a/packages/wb/src/scripts/execution/baseExecutionScripts.ts +++ b/packages/wb/src/scripts/execution/baseExecutionScripts.ts @@ -18,8 +18,8 @@ export interface TestE2EOptions extends TestE2EDevOptions { export abstract class BaseExecutionScripts { protected constructor(private readonly defaultPort = 3000) {} - buildDocker(argv: ScriptArgv, wbEnv = 'local'): string { - return dockerScripts.buildDevImage(wbEnv); + buildDocker(): string { + return dockerScripts.buildDevImage(); } abstract start(argv: ScriptArgv): string; @@ -27,7 +27,7 @@ export abstract class BaseExecutionScripts { abstract startProduction(argv: ScriptArgv, port: number): string; startDocker(argv: ScriptArgv): string { - return `${this.buildDocker(argv)} + return `${this.buildDocker()} && YARN concurrently --raw --kill-others-on-fail "${dockerScripts.stopAndStart(false, argv.normalizedDockerArgsText ?? '', argv.normalizedArgsText ?? '')}" "${this.waitAndOpenApp(argv, 8080)}"`; diff --git a/packages/wb/src/scripts/execution/httpServerScripts.ts b/packages/wb/src/scripts/execution/httpServerScripts.ts index a5817cae..7c9453b7 100644 --- a/packages/wb/src/scripts/execution/httpServerScripts.ts +++ b/packages/wb/src/scripts/execution/httpServerScripts.ts @@ -19,7 +19,7 @@ class HttpServerScripts extends BaseExecutionScripts { } override startDocker(argv: ScriptArgv): string { - return `${this.buildDocker(argv)} && ${dockerScripts.stopAndStart( + return `${this.buildDocker()} && ${dockerScripts.stopAndStart( false, argv.normalizedDockerArgsText ?? '', argv.normalizedArgsText ?? '' diff --git a/packages/wb/src/scripts/execution/plainAppScripts.ts b/packages/wb/src/scripts/execution/plainAppScripts.ts index d481f7e8..f83b0d5b 100644 --- a/packages/wb/src/scripts/execution/plainAppScripts.ts +++ b/packages/wb/src/scripts/execution/plainAppScripts.ts @@ -18,7 +18,7 @@ class PlainAppScripts extends BaseExecutionScripts { } override startDocker(argv: ScriptArgv): string { - return `${this.buildDocker(argv)} && ${dockerScripts.stopAndStart( + return `${this.buildDocker()} && ${dockerScripts.stopAndStart( false, argv.normalizedDockerArgsText ?? '', argv.normalizedArgsText ?? ''