首页 > 解决方案 > 在托管 git 子模块的 docker 中使用 Yarn

问题描述

我有一个开发环境 git repo,其中包含我的应用程序的所有各种组件作为子模块,并且每个子模块都有自己的 docker 容器,这些容器将文件夹作为卷安装。

一些子模块也需要彼此,所以为了减少混淆,我只是将它们列在我的 package.json 中

{
 "dependencies": {
    //...
    "myapp-common": "https://path-to-my-repo.git",
   }
}

这很好用,除非我需要yarn从我的 docker 中运行。当我使用node-sass不同的软件包时,安装取决于yarn正在运行的操作系统。

我遇到的问题是当我运行yarn install等时,我收到此错误:

root@ea69cb8f4e7f:/app# yarn
yarn install v1.10.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads https://path-to-my-repo.git
Directory: /app
Output:
fatal: Not a git repository: ../.git/modules/myapp
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

任何想法如何解决这个问题?

标签: gitdockeryarnpkg

解决方案


不是最理想的,但我通过创建一个临时移动.git文件的 bash 脚本解决了这个问题

#!/bin/bash
mv /app/.git /app/.git.bak
yarn
mv /app/.git.bak /app/.git
yarn start

推荐阅读