@aayush-dev/dockerizer
v1.0.10
Published
Dockerizer is an intelligent, zero-config utility that automatically analyzes your Node.js projects, detects frameworks, databases, and capabilities, and generates optimized, production-ready `Dockerfile` and `.dockerignore` files customized for your proj
Readme
🐳 Dockerizer
Dockerizer is an intelligent, zero-config utility that automatically analyzes your Node.js projects, detects frameworks, databases, and capabilities, and generates optimized, production-ready Dockerfile and .dockerignore files customized for your project.
🔄 Interactive Flow of the Application
Below is an interactive and visual overview of how Dockerizer processes your application. Expand each step to see the underlying code files and operations!
📊 Pipeline Architecture
graph TD
Start([index.js]) -->|Calls| Orchestrator[analyze.js]
Orchestrator -->|1. Walk Dir| Scanner[walkDirectory.js]
Orchestrator -->|2. Parse Dependencies| Analyzer[packageAnalyzer.js]
Orchestrator -->|3. Match Tech Stack| Detector[frameworkDetector.js]
Orchestrator -->|4. Get User Preferences| Questions[askQuestions / CLI Prompts]
Orchestrator -->|5. Build & Cmd Config| Configurator[Auto-resolve CMD & Build Steps]
Configurator -->|6. Generate Files| Generator[dockerfileGenerator.js]
Generator -->|Writes| Dockerfile[Dockerfile]
Generator -->|Writes| Dockerignore[.dockerignore]
classDef stage fill:#2b3a4a,stroke:#3b82f6,stroke-width:2px,color:#fff;
classDef files fill:#1e293b,stroke:#10b981,stroke-width:2px,color:#fff;
class Scanner,Analyzer,Detector,Generator,Questions files;
class Orchestrator stage;🛠️ Step-by-Step Breakdown (Click to Expand)
- File: index.js
- Role: Serves as the CLI entry point. It bootstraps the entire analyzer command.
- Orchestration File: src/commands/analyze.js
- Coordinates all components by feeding output from the scanner and analyzer into the detector, verifying configurations with the user, and invoking the generator.
- File: src/scanner/walkDirectory.js
- Role: Recursively crawls the current working directory (
process.cwd()). - Details:
- Ignores large/system folders like
node_modulesand.git. - Normalizes file paths cross-platform to forward slashes (
/). - Identifies if critical configuration files (e.g.
package.json,package-lock.json) exist.
- Ignores large/system folders like
- File: src/analyzer/packageAnalyzer.js
- Role: Inspects project-specific metadata.
- Details:
- Reads the root-level
package.json. - Extracts lists of
dependenciesanddevDependencies. - Checks if a main entry point (
main) or executable start/dev scripts are defined.
- Reads the root-level
- File: src/detectors/frameworkDetector.js
- Role: Matches project dependencies against known tech-stack blueprints.
- Detections:
- Frameworks:
express,next,nest,fastify,koa,react,react-vite,vue,nuxt,angular,svelte, or defaultnode. - Databases:
mongodb,postgresql,mysql,sqlite, orsequelize. - Support Features: Realtime connections (
socket.io,ws), File Uploads (multer,formidable), and Caching (redis,ioredis).
- Frameworks:
- Function:
askQuestionsin src/commands/analyze.js - Role: Interactive user confirmation.
- Details:
- Displays the auto-detected configuration.
- If some features were not detected, allows the user to manually override and set databases, realtime, caching, or file uploads.
- Asks for the port to expose in the container, suggesting sensible framework defaults (e.g.,
8000for Express,80for React,3000for general node).
- Function: inside src/commands/analyze.js
- Role: Computes Docker build steps.
- Details:
- Resolves standard run commands:
npm start,npm run dev, ornode <file>.jsbased on scripts and entrypoints. - Appends Vite host flags (
-- --host) if necessary so the dev server binds correctly inside the container. - Determines if a build step (
RUN npm run build) is required for front-end and SPA architectures.
- Resolves standard run commands:
- File: src/generators/dockerfileGenerator.js
- Role: Writes the final production files.
- Details:
- Dynamically selects one of the templates from
templates/(e.g.node,express,next,react). - Injects variables:
{{NODE_VERSION}}: Inherited directly from your local machine's running Node.js version.{{PORT}}: User-confirmed port.{{BUILD_STEP}}: E.g.RUN npm run build.{{CMD}}: Start command formatted as a JSON array (e.g.["npm", "start"]).
- Generates
.dockerignoreto keep your Docker context clean, excluding build logs, local node modules, and credentials/environment files (.env).
- Dynamically selects one of the templates from
🚀 Getting Started
Run the tool in your project root:
npx @aayush-dev/dockerizerThe terminal will guide you through confirmation, and output your configured Dockerfile and .dockerignore!
