Docker内部的Git子模块

时间:2018-09-05 08:32:14

标签: git docker yarnpkg

我的应用具有以下结构:

/app
  /web
    /submodule
    package.json
    yarn.lock
    Dockerfile
.gitsubmodule
docker-compose.yml

/ app / web中的Dockerfile:

# build
FROM node:10 AS build-env
WORKDIR /usr/src/app

COPY package.json /usr/src/app/
COPY yarn.lock /usr/src/app/
RUN yarn install

COPY . /usr/src/app/
RUN yarn build

# run
FROM nginx

COPY --from=build-env /usr/src/app/storybook-static /usr/share/nginx/html

在package.json submodule中包含为依赖项:

  "dependencies": {
    "submodule": "file:./submodule",

当docker build运行yarn install命令时,会引发错误:

Building web
Step 1/9 : FROM node:10 AS build-env
 ---> c0cfd9444538
Step 2/9 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 31d2e6122773
Step 3/9 : COPY package.json /usr/src/app/
 ---> Using cache
 ---> 385af24cf951
Step 4/9 : COPY yarn.lock /usr/src/app/
 ---> Using cache
 ---> 861576eec879
Step 5/9 : RUN yarn install
 ---> Running in edde173d5035
yarn install v1.9.2
[1/4] Resolving packages...
error Package "submodule" refers to a non-existing file '"/usr/src/app/submodule"'.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR: Service 'web' failed to build: The command '/bin/sh -c yarn install' returned a non-zero code: 1

如果在没有docker的情况下运行yarn install,一切都很好。如何解决这个问题?

0 个答案:

没有答案