【发布时间】:2019-07-03 22:32:38
【问题描述】:
我正在拼命尝试将我的 NPM 包发布到我们的 NPM 存储库。 我不断收到一条错误消息,指出我的工作目录不干净,我无法理解它。
这是我的 Dockerfile:
FROM node:12
ARG VERSION
COPY .npmrc /root/.npmrc
COPY .gitconfig /root/.gitconfig
COPY .git-credentials /root/.git-credentials
WORKDIR /home/node/app/
COPY package.json package.json
RUN npm install
COPY . .
RUN npm run release:testless -- ${VERSION}
package.json:
"scripts": {
"prepare": "npm run prepare:util",
"prepare:util": "npm explore vl-ui-util -- npm run install:copy",
"test": "wct -l chrome,firefox --npm",
"release": "npm run release:prepare && np",
"release:prepare": "npm run release:prepare:build",
"release:prepare:build": "npm run build",
"release:prepare:commit": "git add -f vl-map.js && git commit --amend --no-edit && git pull",
"release:testless": "npm run release:prepare && np --yolo",
"demo": "npm run dev",
"dev": "concurrently \"npm:bundle:watch\" \"http-server\"",
"build": "npm run bundle:build",
"bundle:watch": "rollup --config rollup.config.js --watch",
"bundle:build": "rollup --config rollup.config.js"
}
这会导致:
npm ERR! Git working directory not clean.
【问题讨论】:
-
你已经复制了所有内容,显然包括你的
.git/目录,然后在其中构建了一些新文件。也许看看docs.docker.com/engine/reference/builder/#dockerignore-file -
我不会把它放在我的 Dockerfile 中。如果我有一些已在本地验证过的更改,并且我正在尝试构建一个 Docker 映像以在实际部署之前对其进行测试,我不希望我的未完全测试的代码发布到 NPM。我也不希望人们从我构建的图像中
docker cp有效的 GitHub 凭据。在 Docker 之外运行它。 -
@jonrsharpe 如果我不复制到我的 .git 文件夹中,我将无法在容器内执行任何 git 操作,因为它不会被识别为 git repo。 AT David,它是在没有节点环境的 Bamboo 上运行的,所以它必须构建在具有节点环境的容器中。