Warm tip: This article is reproduced from stackoverflow.com, please click
docker git node.js npm

Publish NPM package from inside docker container

发布于 2020-03-27 10:23:30

I am desperately trying to publish my NPM package to our NPM repo. I keep getting an error stating that my working directory is not clean and I can't get my head around it.

This is my 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"
  }

This results in:

npm ERR! Git working directory not clean.
Questioner
Homewrecker
Viewed
125
Homewrecker 2019-07-03 22:32

I solved it by cloning inside the container instead of letting Bamboo do the clone and copy all my source files into the container.