Deployment with Docker
You can run npm-check-updates
in a Docker container for consistent and isolated execution, which is especially useful in CI/CD environments.
Dockerfile
The project includes a Dockerfile
for this purpose:
FROM node:latest
RUN npm install -g npm-check-updates
WORKDIR /app
ENTRYPOINT ["npm-check-updates"]
Building the Image
To build the Docker image, navigate to the root of the npm-check-updates
project and run:
docker build -t npm-check-updates .
Running the Container
To use the Docker image on your own project, mount your project's directory to the /app
volume inside the container. This allows ncu
to access your package.json
.
Checking for Updates
docker run --rm -it -v "/path/to/your/project:/app" npm-check-updates
--rm
: Automatically removes the container when it exits.-it
: Runs the container in interactive mode with a TTY.-v
: Mounts the host directory/path/to/your/project
to the container's/app
directory.
Upgrading Dependencies
You can pass any ncu
command-line arguments after the image name:
# Upgrade the package.json and format the output
docker run --rm -it -v "/path/to/your/project:/app" npm-check-updates -u --format group
Since the project directory is mounted as a volume, any changes made to package.json
by ncu -u
will be reflected on your host machine.