boilerplate icon indicating copy to clipboard operation
boilerplate copied to clipboard

Dockerfile - should `npm ci` be used?

Open jameswragg opened this issue 1 year ago • 3 comments
trafficstars

Referring to the following line: https://github.com/hapipal/boilerplate/blob/d1b4fda62eb8aaff10c78eea34096b3164555c6e/server/Dockerfile#L21

npm provides the npm ci command to install the versions specified in the package-lock.json. If your container is being built by CI & test are run with it, I believe you'd want the same versions as those running locally so should the command be npm ci here?

jameswragg avatar Dec 04 '23 17:12 jameswragg

Yes, that seems right! Will leave this issue open until that's settled.

devinivy avatar Dec 07 '23 17:12 devinivy

As I mentioned on Discord on this previous topic, I believe it'd be a nice addition. You could also leverage multi-steps Docker image if you'd want to use npm i for dev and npm ci for prod. The problem would be that you'll be installing the dependencies two times when building for prod which might not be ideal. It's probably better to only use npm ci.

Nargonath avatar Dec 08 '23 05:12 Nargonath

@jameswragg in case we move forward with this, do you wan to make the PR?

Nargonath avatar Dec 08 '23 05:12 Nargonath