小编ali*_*ien的帖子

每次使用 docker-compose 时,yarn install 链接依赖项都很慢

我对使用 docker 不是很熟悉,这是将开发环境迁移到 docker 的大型企业应用程序的一部分。

现在,yarn install 在 docker 之外大约需要10 分钟才能完成,这主要是Linking Dependencies...逐步完成的,因为我猜有超过 3 万个对象要链接。在第一个之后yarn install,只需1 秒即可完成。如果我更改一个依赖项,大约需要10 秒才能完成。所以它比10分钟快得多!

但是在 docker 内部,无论依赖项是否改变,每次大约需要5-10 分钟

任何想法为什么会发生这种情况?

我们使用 docker-compose 并有几个不同的进程,其中之一是节点服务器。每当 package.json 更改时,节点服务器都会运行 yarn install,但这种情况相当频繁(每天更新几次)。所以 yarn install 一天运行几次。理想情况下,这将与在 docker 之外运行它一样快,但我不确定从哪里开始寻找。是否有设置或某些东西可以删除每个上的纱线缓存docker-compose restart node,或者什么?

我们基本上有这个docker-compose.yml

services:
  ...
  node:
    image: myimage:latest
    ...
    volumes:
      - ./:/app:cached
      - ./node_modules_docker:/app/node_modules:cached
    working_dir: /app
    ...
  ...
Run Code Online (Sandbox Code Playgroud)

filesystems performance docker docker-compose yarnpkg

12
推荐指数
1
解决办法
4901
查看次数

如何在 TypeScript React 组件中返回字符串或 JSX 元素?

我收到这个奇怪的 TypeScript 错误:

import React from 'react'

type Props = {
  children: string
}

const Container = (props: Props) => {
  const isNew = true // make an api call...

  if (isNew) {
    return <NewContainer {...props} />
  } else {
    return <OldContainer {...props} />
  }
}

const NewContainer = ({ children }: Props) => {
  const isSpecial = useIsSpecial()

  if (!children) {
    return null
  }

  if (!isSpecial) {
    return children
  }

  return <a>{children}</a>
}

const OldContainer = ({ children }: …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs

11
推荐指数
2
解决办法
2万
查看次数

如何在 github 操作中运行 git diff

我得到这个:

Command failed: git diff --name-only HEAD^..HEAD
fatal: ambiguous argument 'HEAD^..HEAD': unknown revision or path not in the working tree.
Run Code Online (Sandbox Code Playgroud)

我想git diff --name-only HEAD^..HEAD在我的分支中运行以获取已更改文件的列表。它在本地工作,但不在 GitHub 操作上。我必须做什么?

我的代码是这样的:

name: build
on:
  push:
    branches:
      - main
jobs:
  run:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
      - name: Configure Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 14.x
      - name: Install dependencies
        run: yarn install
      - name: Publish file changes to Slack
        # HERE I run `git diff` in node.js …
Run Code Online (Sandbox Code Playgroud)

git github-actions

2
推荐指数
2
解决办法
2173
查看次数