Docker-Compose Build在脚本中使用纱线安装挂起

发布于 2025-02-07 14:24:32 字数 3526 浏览 3 评论 0原文

我有这个脚本,在其中放置了Docker-Compose构建,并且在运行纱线安装结束时悬挂着:

[3/4] Linking dependencies...
warning " > @craco/[email protected]" has incorrect peer dependency "react-scripts@^4.0.0".
warning "@craco/craco > [email protected]" has unmet peer dependency "@types/node@*".
warning "@craco/craco > [email protected]" has incorrect peer dependency "typescript@>=3".
warning "@craco/craco > cosmiconfig-typescript-loader > [email protected]" has unmet peer dependency "@types/node@*".
warning " > @testing-library/[email protected]" has unmet peer dependency "@testing-library/dom@>=7.21.4".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 175.73s.
^CBuild complete.

您可以看到我用Ctrl+C打断了悬挂式,然后它说“构建完整”。 这样可以防止我的脚本继续进行Docker-Compose ...

我有此Docker-compose.yml文件:

version: '3.7'

services:
  
  frontend:
    build:
      context: .
      dockerfile: ./compose/production/build/Dockerfile
    restart: always
    stdin_open: true
    ports:
      - 80:80
    volumes:
      - staticfiles:/app/static
      - mediafiles:/app/media
    depends_on:
      - backend
    networks:
      spa_network:
        ipv4_address: 172.20.128.3

  backend:
    build:
      context: .
      dockerfile: ./compose/production/django/Dockerfile
    restart: always
    command: /start
    volumes:
      - staticfiles:/app/static
      - mediafiles:/app/media
      - sqlite_db:/app/db  
    ports:
      - 8000:8000
    env_file:
      - ./env/prod-sample
    networks:
      spa_network:
        ipv4_address: 172.20.128.2

networks:
  spa_network:
    ipam:
      config:
        - subnet: 172.20.0.0/16

volumes:
  sqlite_db:
  staticfiles:
  mediafiles:

并且悬挂的构建具有此dockerfile:

FROM node:14-stretch-slim as frontend-builder

WORKDIR /app/frontend
COPY ./frontend .
ENV PATH ./node_modules/.bin/:$PATH
RUN yarn install
RUN yarn build 

###############################################

FROM nginx:1.19.2-alpine

RUN rm /etc/nginx/conf.d/default.conf
COPY ./compose/production/build/nginx.conf /etc/nginx/conf.d
COPY --from=frontend-builder /app/frontend/build /usr/share/nginx/html/build

请注意,构建仅在第一个构建时悬挂。当我重新运行构建过程(docker-compose build),并且它在缓存中正在处理下一个运行命令...

我尝试使用sudo docker-compose-build -d但这是一样的...也许它与纱线有关吗?

该问题在此处描述: https://github.com/yarnpkg/yarnpkg/yarn/yarn/yarn/issues/66605 <<66605 << /a> 但是他们说这不是纱线

,他们指向那里 https:/github.com /yarnpkg/yarn/essugy/749#issuecomment-253317395 使用 -

我尝试使用的 - no缓存 - 不 - cache,no cache却相同。它在“在x s中完成”之后悬挂。

I have this script where i put docker-compose build and it hangs at the end of the RUN yarn install:

[3/4] Linking dependencies...
warning " > @craco/[email protected]" has incorrect peer dependency "react-scripts@^4.0.0".
warning "@craco/craco > [email protected]" has unmet peer dependency "@types/node@*".
warning "@craco/craco > [email protected]" has incorrect peer dependency "typescript@>=3".
warning "@craco/craco > cosmiconfig-typescript-loader > [email protected]" has unmet peer dependency "@types/node@*".
warning " > @testing-library/[email protected]" has unmet peer dependency "@testing-library/dom@>=7.21.4".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 175.73s.
^CBuild complete.

You can see I interrupted the hang with ctrl+c and after that the it says "build complete".
This prevents my script to continue with docker-compose up...

I have this docker-compose.yml file:

version: '3.7'

services:
  
  frontend:
    build:
      context: .
      dockerfile: ./compose/production/build/Dockerfile
    restart: always
    stdin_open: true
    ports:
      - 80:80
    volumes:
      - staticfiles:/app/static
      - mediafiles:/app/media
    depends_on:
      - backend
    networks:
      spa_network:
        ipv4_address: 172.20.128.3

  backend:
    build:
      context: .
      dockerfile: ./compose/production/django/Dockerfile
    restart: always
    command: /start
    volumes:
      - staticfiles:/app/static
      - mediafiles:/app/media
      - sqlite_db:/app/db  
    ports:
      - 8000:8000
    env_file:
      - ./env/prod-sample
    networks:
      spa_network:
        ipv4_address: 172.20.128.2

networks:
  spa_network:
    ipam:
      config:
        - subnet: 172.20.0.0/16

volumes:
  sqlite_db:
  staticfiles:
  mediafiles:

and the build which is hanging has this dockerfile:

FROM node:14-stretch-slim as frontend-builder

WORKDIR /app/frontend
COPY ./frontend .
ENV PATH ./node_modules/.bin/:$PATH
RUN yarn install
RUN yarn build 

###############################################

FROM nginx:1.19.2-alpine

RUN rm /etc/nginx/conf.d/default.conf
COPY ./compose/production/build/nginx.conf /etc/nginx/conf.d
COPY --from=frontend-builder /app/frontend/build /usr/share/nginx/html/build

Notice the build is hanging only on first build. When i rerun the build process (docker-compose build) and it is in cache it is processing the next RUN command...

I've tried to use sudo docker-compose up --build -d but it's the same...maybe it has something to do with yarn?

The issue is described here : https://github.com/yarnpkg/yarn/issues/6605
but they say it's not yarn

And they point to there https://github.com/yarnpkg/yarn/issues/749#issuecomment-253317395 to use --no cache

I've tried to use --no cache and it is the same. It hangs after "Done in x s."

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞美少年 2025-02-14 14:24:32

显然,运行以下命令:

   RUN set -ex; \
      yarn install --frozen-lockfile --production; \
      yarn cache clean; \
      yarn run build

代替

RUN yarn install 
RUN yarn build 

在Dockerfile中似乎可以正常工作

Apparently, running the following commands :

   RUN set -ex; \
      yarn install --frozen-lockfile --production; \
      yarn cache clean; \
      yarn run build

instead of

RUN yarn install 
RUN yarn build 

in the Dockerfile seems to work properly

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文