Skip to content

Latest commit

 

History

History
109 lines (70 loc) · 2.71 KB

File metadata and controls

109 lines (70 loc) · 2.71 KB

Dockerizer Usage Guide

Introduction

Dockerizer is an autonomous tool that helps you containerize your monorepo applications with minimal effort. This guide explains how to use the tool effectively.

Quick Start

Install the tool:

npm install -g dockerizer

Navigate to your monorepo and run the tool:

cd your-monorepo
dockerizer

Follow the interactive prompts to configure your Docker setup.

Example: Dockerizing a Monorepo

Let's use the example monorepo included in this package to demonstrate how to use Dockerizer.

Step 1: Navigate to the Example

cd example

Step 2: Run Dockerizer

../bin/dockerizer.js

The tool will:

  1. Scan the repository structure
  2. Identify the services (frontend, backend, worker)
  3. Ask you which services you want to include
  4. Generate Dockerfiles for each service
  5. Create appropriate docker-compose files
  6. Test the Docker configuration
  7. Fix any issues automatically

Step 3: Use the Generated Docker Setup

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 up

Advanced Usage

Command Line Options

dockerizer --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)

Common Patterns

Dockerizing a Next.js Frontend with Express Backend

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

Handling Different Environments

Choose between a single docker-compose file or separate development/production files during the configuration phase.

Custom Modifications

You can modify the generated Dockerfiles and docker-compose files to:

  • Add custom environment variables
  • Configure custom build steps
  • Adjust service networking

Troubleshooting

If the auto-healing can't fix an issue:

  1. Check the verification report in the generated dockerizer-report-*.md file
  2. Look at specific error messages in the log
  3. Manually adjust the Dockerfiles or docker-compose files

Extending the Tool

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