简体   繁体   English

docker 中的 Angular 与 lerna 未构建

[英]Angular in docker with lerna not building

I'm trying to deploy a single Angular client from my lerna monorepo via docker.我正在尝试通过 docker 从我的 lerna monorepo 部署单个 Angular 客户端。

For this I created the following Docker file.为此,我创建了以下 Docker 文件。

# Build environment
FROM node:12.2.0-alpine as build

# Work dir
WORKDIR /usr/src/app

# Set env values
ENV LOG_LEVEL=debug
ENV NODE_ENV=production

# Add lerna
COPY package.json .
COPY lerna.json .
RUN npm i lerna @angular/cli -g --loglevel notice

# Copy packages
COPY packages/client ./packages/client

# bootstrap
RUN yarn install --production --no-optional
RUN lerna bootstrap --scope=@proj/client -- --production --no-optional

# build
RUN lerna run build:prod --scope=@proj/client

# Run environment
FROM nginx:1.16.0-alpine
COPY --from=build ./packages/client/dist/client /usr/share/nginx/html
COPY --from=build ./packages/client/.nginx/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

But when running docker build -t test -f packages/client/Dockerfile .但是当运行docker build -t test -f packages/client/Dockerfile . it gives me following error:它给了我以下错误:

lerna notice cli v3.22.1
lerna notice filter including "@proj/client"
lerna info filter [ '@proj/client' ]
lerna info Executing command in 1 package: "yarn run build:prod"
lerna ERR! yarn run build:prod exited 127 in '@proj/client'
lerna ERR! yarn run build:prod stdout:
yarn run v1.15.2
$ ng build --prod
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

lerna ERR! yarn run build:prod stderr:
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /usr/local/lib/node_modules/@angular/cli/models/architect-command.js
- /usr/local/lib/node_modules/@angular/cli/commands/build-impl.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /usr/local/lib/node_modules/@angular/cli/utilities/json-schema.js
- /usr/local/lib/node_modules/@angular/cli/models/command-runner.js
- /usr/local/lib/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng
See "/tmp/ng-OFgChe/angular-errors.log" for further details.
error Command failed with exit code 127.

I've tried several combinations of the #bootstrap block:我已经尝试了 #bootstrap 块的几种组合:

  • I've tried with and without the yarn install我试过有和没有yarn install
  • I've tried removing the --production and --no-optional flags我试过删除--production--no-optional标志
  • I've tried moving the devDependencies to the root package.json我试过将devDependencies移动到根package.json

Running these commands local (on a cleaned working folder) works perfectly, but each one of them gives me the same result in my docker build.在本地(在清理过的工作文件夹上)运行这些命令可以完美运行,但是在我的 docker 构建中,它们中的每一个都给了我相同的结果。 So it's not that the @angular-devkit isn't listed as dependecy所以并不是@angular-devkit没有被列为依赖项

Anybody got any clue on how to resolve this?有人知道如何解决这个问题吗?

Found out how to resolve it.发现如何解决它。 Apparently with or without the --production didn't matter for yarn显然有或没有--production纱线来说并不重要

changing it to --production=false or changing the NODE_ENV to something else fixes the issue将其更改为--production=false或将NODE_ENV更改为其他内容可以解决问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 5和lerna NullInjectorError:没有InjectionToken的提供者 - Angular 5 and lerna NullInjectorError: No provider for InjectionToken 使用angular 2,jupyter和typescript构建docker镜像 - Building docker image with angular 2, jupyter and typescript 在 Docker 上构建 Node/NPM Angular 镜像时出错 - Error building Node/NPM Angular image on Docker 在Google Container Builder上使用Docker构建Angular应用程序失败 - Building Angular application with Docker on Google Container Builder fails 使用 docker 构建 angular 应用程序时的 node_modules 卷技巧 - The node_modules Volume Trick when building an angular app with docker 使用 Docker 构建 Angular 失败:nginx.conf - 没有这样的文件 - Building Angular with Docker fails: nginx.conf - no such file 在 Azure devops 中构建 angular 应用程序 docker 文件时失败 - Failure while building angular app docker file in Azure devops Angular 9 和 docker 为什么 docker 只返回 doc 文件夹而不是构建应用程序? - Angular 9 and docker why docker is only returning doc folder instead of building the app? 如何使用打字稿解决lerna monorepo中sequelize和angular之间的冲突? - How to solve conflict between sequelize and angular in lerna monorepo with typescript? 在 Docker 中构建 Angular 会抛出“文件替换中的 environment.prod.ts 路径不存在” - Building Angular in Docker throws "environment.prod.ts path in file replacements does not exist"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM