Skip to content

Commit

Permalink
fix(wb): make 'docker build' refer to WB_ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Oct 8, 2023
1 parent b41cd8b commit a85e349
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/wb/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function test(argv: ArgumentsCamelCase<InferredOptionTypes<typeof b
// Check playwright installation because --ci includes --e2e implicitly
if (argv.e2e !== 'none' && (await e2eTestsExistPromise)) {
if (project.hasDockerfile) {
await runWithSpawn(`${scripts.buildDocker(argv, 'test')}`, argv);
await runWithSpawn(`${scripts.buildDocker()}`, argv);
}
const options = project.hasDockerfile
? {
Expand Down Expand Up @@ -158,7 +158,7 @@ async function testOnDocker(
scripts: BaseExecutionScripts,
prefix = ''
): Promise<void> {
await runWithSpawn(`${scripts.buildDocker(argv, 'test')}`, argv);
await runWithSpawn(`${scripts.buildDocker()}`, argv);
process.exitCode = await runWithSpawn(
`${prefix}${scripts.testE2E(argv, {
startCommand: dockerScripts.stopAndStart(true),
Expand Down
4 changes: 2 additions & 2 deletions packages/wb/src/scripts/dockerScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 && '
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions packages/wb/src/scripts/execution/baseExecutionScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ 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;

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)}"`;
Expand Down
2 changes: 1 addition & 1 deletion packages/wb/src/scripts/execution/httpServerScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? ''
Expand Down
2 changes: 1 addition & 1 deletion packages/wb/src/scripts/execution/plainAppScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? ''
Expand Down

0 comments on commit a85e349

Please sign in to comment.