Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Docker容器启动monorepo应用程序速度慢_Angular_Docker_Nestjs_Monorepo_Nrwl Nx - Fatal编程技术网

Angular Docker容器启动monorepo应用程序速度慢

Angular Docker容器启动monorepo应用程序速度慢,angular,docker,nestjs,monorepo,nrwl-nx,Angular,Docker,Nestjs,Monorepo,Nrwl Nx,当我运行docker compose通过NX构建Angular和Nest应用程序的monorepo时,构建速度很快,但容器运行得非常慢。但如果我直接在mac上运行这些应用程序,它的构建速度会非常快。我希望应用程序在docker中构建得更快 下面是my docker-compose.yml中的一个服务示例: dollop-accounts-web: command: npm start dollop-accounts-web build: args:

当我运行docker compose通过NX构建Angular和Nest应用程序的monorepo时,构建速度很快,但容器运行得非常慢。但如果我直接在mac上运行这些应用程序,它的构建速度会非常快。我希望应用程序在docker中构建得更快

下面是my docker-compose.yml中的一个服务示例:

  dollop-accounts-web:
    command: npm start dollop-accounts-web
    build:
      args:
        - NODE_VERSION=${NODE_VERSION}
        - PORT=${ACCOUNTS_WEB_PORT}
      context: .
    container_name: dollop-accounts-web
    image: dollop-node-image
    ports:
      - ${ACCOUNTS_WEB_PORT}:${ACCOUNTS_WEB_PORT}
    volumes:
      - .:/usr/src/app
这是我所有服务使用的dockerfile(注意,我为每个容器复制了整个monorepo,因为我不知道如何更好地处理它):

我运行7个类似的服务,我有一个Nest应用程序的此类日志:

> dollop@1.0.0 start /usr/src/app
> nx serve "dollop-accounts-service"


> nx run dollop-accounts-service:serve 
Starting type checking service...
Using 2 workers with 2048MB memory limit
这类日志用于和角度应用程序:

> dollop@1.0.0 start /usr/src/app
> nx serve "dollop-tasks-web"


> nx run dollop-tasks-web:serve 
WARNING: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disableHostCheck" if that's the
case.
Another process, with id 35, is currently running ngcc.
Waiting up to 250s for it to finish.
(If you are sure no ngcc process is running then you should delete the lock-file at /usr/src/app/node_modules/@angular/compiler-cli/ngcc/__ngcc_lock_file__.)

正如你所见,它很难一次启动所有的应用程序。但即使只有一个服务,它也比我在主机上运行时慢得多。有没有办法对此进行优化?

您没有在映像中运行代码;您正在使用
卷:
用其他代码覆盖该卷。这在MacOS上非常慢。删除
卷:
,它会运行得更好。(您可以构建一个映像,并在
docker compose.yml
文件中为从中启动的每个容器指定另一个
命令:
)。因此,我需要保留卷,这样就不必为每次更改重新启动容器。此外,我对卷使用mongodb、elasticsearch和redis,它们运行正常。我试图删除卷,但问题仍然存在。ngcc和typescript类型检查似乎不能同时在多个容器上运行;您正在使用
卷:
用其他代码覆盖该卷。这在MacOS上非常慢。删除
卷:
,它会运行得更好。(您可以构建一个映像,并在
docker compose.yml
文件中为从中启动的每个容器指定另一个
命令:
)。因此,我需要保留卷,这样就不必为每次更改重新启动容器。此外,我对卷使用mongodb、elasticsearch和redis,它们运行正常。我试图删除卷,但问题仍然存在。ngcc和typescript类型检查似乎不能同时在多个容器上运行。
> dollop@1.0.0 start /usr/src/app
> nx serve "dollop-tasks-web"


> nx run dollop-tasks-web:serve 
WARNING: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disableHostCheck" if that's the
case.
Another process, with id 35, is currently running ngcc.
Waiting up to 250s for it to finish.
(If you are sure no ngcc process is running then you should delete the lock-file at /usr/src/app/node_modules/@angular/compiler-cli/ngcc/__ngcc_lock_file__.)