-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnpm-install-docker.sh
executable file
·17 lines (13 loc) · 1.11 KB
/
npm-install-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
# Run npm install in a Docker container built from the same base image as our app's Docker container (see app/Dockerfile), and mount our app folder as a volume in that container so that our local package-lock.json file is updated.
# This package-lock.json file is then used in our app's Docker container when we run npm ci (which requires a package-lock.json file that matches the package.json file, and runs more quickly than a regular npm install).
# Doing npm install only in this Docker container should mean the resulting package-lock.json file always works reliably in our app's Docker container. (Well, as reliably as possible, given the limits of npm.)
docker \
run \
--rm \
--tty \
--volume "$(pwd)/src:/workdir" \
--volume /workdir/node_modules \
--workdir /workdir \
node:20-alpine \
/bin/sh -c "npm install --no-optional --loglevel error; npm outdated"