docs(nvm): Document nvm usage in Dockerfiles and CI/CD workflows
- Add comprehensive NVM usage section to README - Document Dockerfile RUN command usage - Document CI/CD workflow integration - Explain nvm vs npmci comparison - Add technical implementation notes to readme.hints.md - Update changelog with v5.0.147 feature details Includes: - Direct nvm usage examples for Dockerfiles - CI/CD workflow YAML examples - Version persistence behavior documentation - Multi-version testing examples - Technical architecture details - Maintenance guidelines
This commit is contained in:
59
readme.md
59
readme.md
@@ -41,6 +41,65 @@ RUN npmci install 14.17.0
|
||||
|
||||
In this example, `npmci` installs Node.js version `14.17.0` and sets it as the default.
|
||||
|
||||
### Using NVM in Dockerfiles
|
||||
|
||||
The base image includes **nvm (Node Version Manager)** for flexible Node.js version management. Use nvm commands directly in Dockerfile RUN statements without any sourcing required:
|
||||
|
||||
```dockerfile
|
||||
FROM registry.gitlab.com/hosttoday/ht-docker-node:latest
|
||||
|
||||
# Use nvm directly - no sourcing needed
|
||||
RUN nvm install 18.20.0
|
||||
RUN nvm use 18 && npm install
|
||||
|
||||
# Or chain commands
|
||||
RUN nvm install 19.0.0 && nvm use 19 && npm ci
|
||||
```
|
||||
|
||||
**Important**: Each RUN command is a separate shell. To persist version changes across RUN commands, set a new default:
|
||||
|
||||
```dockerfile
|
||||
RUN nvm install 18.20.0 && nvm alias default 18
|
||||
# Subsequent RUN commands will use v18 by default
|
||||
```
|
||||
|
||||
### Using NVM in CI/CD Workflows
|
||||
|
||||
NVM is automatically available in CI/CD workflow scripts when using `bash -c`:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:latest
|
||||
|
||||
steps:
|
||||
- name: Use specific Node version
|
||||
run: |
|
||||
nvm install 18.20.0
|
||||
nvm use 18
|
||||
npm install
|
||||
npm test
|
||||
|
||||
- name: Test multiple versions
|
||||
run: |
|
||||
for version in 16 18 20; do
|
||||
nvm install $version
|
||||
nvm use $version
|
||||
npm test
|
||||
done
|
||||
```
|
||||
|
||||
### NVM vs npmci
|
||||
|
||||
Both tools are available in the image:
|
||||
|
||||
- **nvm**: Standard Node version manager, works in Dockerfiles and CI/CD workflows
|
||||
- **npmci**: CI-focused wrapper with additional shipzone.io features
|
||||
|
||||
Choose based on your preference - they work together seamlessly.
|
||||
|
||||
### Custom Dockerfile with `npmci` and your Node.js App
|
||||
|
||||
You can create a custom Dockerfile for your Node.js application using the `:npmci` flavour:
|
||||
|
||||
Reference in New Issue
Block a user