Dockerizer is an autonomous tool that helps you containerize your monorepo applications with minimal effort. This guide explains how to use the tool effectively.
Install the tool:
npm install -g dockerizerNavigate to your monorepo and run the tool:
cd your-monorepo
dockerizerFollow the interactive prompts to configure your Docker setup.
Let's use the example monorepo included in this package to demonstrate how to use Dockerizer.
cd example../bin/dockerizer.jsThe tool will:
- Scan the repository structure
- Identify the services (frontend, backend, worker)
- Ask you which services you want to include
- Generate Dockerfiles for each service
- Create appropriate docker-compose files
- Test the Docker configuration
- Fix any issues automatically
After successful dockerization, you can:
# Start the services in development mode
docker-compose -f docker-compose.dev.yml up
# Or for production
docker-compose -f docker-compose.prod.yml updockerizer --target-dir=./my-project --verbose --max-retries=5--target-dir: Specify a different directory to dockerize (default: current directory)--verbose: Show detailed logs during the process--max-retries: Set the maximum number of automatic fix attempts (default: 3)
The tool automatically detects Next.js and Express applications and applies appropriate Docker configurations:
- Next.js: Multi-stage build with proper optimization
- Express: Efficient Node.js configuration with dependency installation
Choose between a single docker-compose file or separate development/production files during the configuration phase.
You can modify the generated Dockerfiles and docker-compose files to:
- Add custom environment variables
- Configure custom build steps
- Adjust service networking
If the auto-healing can't fix an issue:
- Check the verification report in the generated
dockerizer-report-*.mdfile - Look at specific error messages in the log
- Manually adjust the Dockerfiles or docker-compose files
You can extend Dockerizer by modifying the source code:
- Add new service type detectors in
src/phases/contextGatherer.js - Create custom Dockerfile templates in
src/phases/codeGenerator.js - Add new error patterns and fixes in
src/phases/executor.js