Docker environment for developing with pnpm workspaces, featuring Node.js 22 and pnpm 9.1.1.
# Clone the repository
git clone <your-repo-url>
cd pnpm-home
# Build the Docker image
./build.sh
# Run the example application
docker run --rm pnpm-home:latest pnpm startpnpm-home/
├── Dockerfile # Docker image definition
├── build.sh # Build script with validations
├── .dockerignore # Docker ignore patterns
├── .gitignore # Git ignore patterns
├── README.md # This file
└── project-workspace/ # Example pnpm workspace project
├── package.json # Workspace root configuration (pnpm version spec)
├── .npmrc # Workspace engine strict mode
├── pnpm-workspace.yaml # Workspace configuration
└── packages/ # Workspace packages
├── utils/ # Utility library (@my-workspace/utils)
└── app/ # Main application (@my-workspace/app)
The pnpm version is specified in project-workspace/package.json using both fields:
{
"packageManager": "pnpm@9.1.1",
"engines": {
"pnpm": "9.1.1"
}
}The build system reads from both packageManager and engines.pnpm fields to ensure version consistency.
- ✅ Debian latest base image
- ✅ Node.js 22 from official repository
- ✅ pnpm 9.1.1 (version controlled via package.json)
- ✅ Non-root user (node)
- ✅ Example workspace project included
- ✅ Engine version validation with .npmrc
- ✅ Dependencies pre-installed in the image
# Install the latest pnpm version locally (for development)
npm install -g pnpm
# Ensure Docker is running
sudo systemctl start docker# Build the image (installs dependencies and creates Docker image)
./build.sh
# Build with custom tag
./build.sh v1.0# Run the example application directly
docker run --rm pnpm-home:latest pnpm start
# Or enter the container interactively
docker run --rm -it pnpm-home:latest
# Inside the container, you can:
pnpm start # Run the main application
pnpm test # Run tests in all packages
ls -la # Explore the workspaceThe included project-workspace demonstrates a simple pnpm workspace with:
Simple utility library with helper functions:
formatDate()- Formats dates to en-UScapitalize()- Capitalizes stringsgenerateId()- Generates random IDs
Simple main application that uses the utilities and prints output with console.log.
When you run the example project, you'll see:
🚀 Application started!
📅 Current date: 7/21/2025
✨ Formatted text: Hello world
🔑 Generated ID: x8k2m9p4q
👥 Users:
- John (john@email.com)
- Jane (jane@email.com)
# Install dependencies
cd project-workspace
pnpm install
# Run the application locally
pnpm start
# Run tests
pnpm test
# Add dependencies to specific packages
pnpm --filter @my-workspace/app add lodash
pnpm --filter @my-workspace/utils add moment# Rebuild after changes
./build.sh
# Run with volume mount for development
docker run --rm -it -v $(pwd)/project-workspace:/workspace pnpm-home:latest- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request