diff --git a/packages/wb/src/project.ts b/packages/wb/src/project.ts index 8ae8959a..81ae7542 100644 --- a/packages/wb/src/project.ts +++ b/packages/wb/src/project.ts @@ -58,14 +58,13 @@ export class Project { @memoizeOne get name(): string { - return this.rootPackageJson.name || 'unknown'; + return this.packageJson.name || 'unknown'; } @memoizeOne - get nameWithoutNamespace(): string { - const name = this.rootPackageJson.name || 'unknown'; - const index = name.lastIndexOf('/'); - return index === -1 ? name : name.slice(index + 1); + get dockerImageName(): string { + const name = this.packageJson.name || 'unknown'; + return name.replaceAll('@', '').replaceAll('/', '-'); } @memoizeOne diff --git a/packages/wb/src/scripts/dockerScripts.ts b/packages/wb/src/scripts/dockerScripts.ts index 4f18b60e..5305134d 100644 --- a/packages/wb/src/scripts/dockerScripts.ts +++ b/packages/wb/src/scripts/dockerScripts.ts @@ -15,7 +15,7 @@ class DockerScripts { : ''; return `cd ${path.dirname(project.findFile('Dockerfile'))} && ${prefix}YARN wb optimizeForDockerBuild --outside - && YARN wb retry -- docker build -t ${project.nameWithoutNamespace} + && YARN wb retry -- docker build -t ${project.dockerImageName} --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64) --build-arg WB_ENV=${project.env.WB_ENV} --build-arg WB_VERSION=dev .`; @@ -29,11 +29,11 @@ class DockerScripts { } start(project: Project, additionalOptions = '', additionalArgs = ''): string { spawnSyncOnExit(this.stop(project), project); - return `docker run --rm -it -p 8080:8080 --name ${project.nameWithoutNamespace} ${additionalOptions} ${project.nameWithoutNamespace} ${additionalArgs}`; + return `docker run --rm -it -p 8080:8080 --name ${project.dockerImageName} ${additionalOptions} ${project.dockerImageName} ${additionalArgs}`; } stop(project: Project): string { - return `true $(docker rm -f $(docker container ls -q -f name=${project.nameWithoutNamespace}) 2> /dev/null)`; + return `true $(docker rm -f $(docker container ls -q -f name=${project.dockerImageName}) 2> /dev/null)`; } stopAll(): string {