dockerez
v1.0.1
Published
Automatically detect projects and generate Dockerfiles, Docker Compose configurations, and Docker environment files.
Maintainers
Readme
Dockerez
Automatically detect supported projects and generate Docker configuration with minimal setup. 🐋
Dockerez scans a project directory, detects supported frameworks and databases, and generates Dockerfiles, .dockerignore files, Docker Compose configurations, and environment templates.
Features
- Recursive project detection
- Automatic Dockerfile generation
- Docker Compose generation
- Database service detection
- Persistent database volumes
- Database healthchecks
- Automatic service dependencies
.env.examplegeneration- Docker configuration cleanup
- Docker environment diagnostics
--forceoverwrite support--no-composemode for Dockerfile-only workflows- npm, Yarn and pnpm detection for Node.js projects
- FastAPI detection for Python projects
Installation
Install from npm
npm install -g dockerezVerify installation
dockerez --versionQuick Start
Navigate to the root directory of your project:
cd my-projectAnalyze the project:
dockerez initGenerate Docker configuration:
dockerez generateDockerez will scan the directory and generate the appropriate Docker configuration based on the detected technologies.
Commands
dockerez init
Analyzes the current directory and reports detected projects and technologies.
dockerez initUse this to inspect what Dockerez detects before generating Docker configuration.
dockerez generate
Generates Docker configuration for detected projects.
dockerez generateDepending on the detected project, Dockerez can generate:
Dockerfile
.dockerignore
docker-compose.yml
.env.exampleExisting files are protected by default.
If a generated file already exists, Dockerez will skip it and display a warning.
dockerez generate --force
Forces dockerez to overwrite existing Docker configuration files.
dockerez generate --forceUse this when you want to regenerate the configuration after changing the project structure or detected technologies.
dockerez generate --no-compose
Generates Dockerfiles and .dockerignore files without generating Docker Compose configuration.
dockerez generate --no-composeThis is useful when you only want containerization for individual projects and do not need a multi-container setup.
For example:
my-project/
├── Dockerfile
└── .dockerignoreNo docker-compose.yml or .env.example is generated by this mode.
You can also combine it with --force:
dockerez generate --force --no-composedockerez clean
Removes Docker-related configuration files from the current project.
dockerez cleanDockerez will first show the files it found and ask for confirmation.
The command can remove:
Dockerfile
Dockerfile.dev
Dockerfile.prod
docker-compose.yml
docker-compose.yaml
.dockerignore
.env.exampleThis command can remove Docker configuration regardless of whether dockerez originally created the files.
dockerez clean --force
Removes detected Docker configuration files without asking for confirmation.
dockerez clean --forceUse this carefully because existing Docker configuration files will be deleted.
dockerez doctor
Checks the local development environment for the tools dockerez relies on.
dockerez doctorThe diagnostic checks include:
- Node.js
- npm
- Docker
- Docker Compose
- Current project
- Common Docker configuration files
Example:
🩺 dockerez Doctor
================
✓ Node.js: v22.x.x
✓ npm: 10.x.x
✓ Docker: Docker version ...
✓ Docker Compose: Docker Compose version ...
Project:
C:\Projects\my-project
✓ package.json: found
✓ Dockerfile: found
✓ docker-compose.yml: found
✅ Doctor check complete.dockerez --help
Displays available commands and options.
dockerez --helpIndividual commands also provide help:
dockerez generate --help
dockerez clean --helpdockerez --version
Displays the installed dockerez version.
Dockerez --versionSupported Technologies
Dockerez currently supports the following project types.
| Technology | Detection | Dockerfile | Compose | | ---------- | --------: | ---------: | ------: | | Vite | ✅ | ✅ | ✅ | | React | ✅ | — | — | | Express | ✅ | ✅ | ✅ | | Next.js | ✅ | ✅ | ✅ | | FastAPI | ✅ | ✅ | ✅ | | PostgreSQL | ✅ | — | ✅ | | MongoDB | ✅ | — | ✅ | | Redis | ✅ | — | ✅ |
React is detected as a frontend technology, while Vite is used as the Docker build strategy for Vite-based frontend applications.
Example Project
A project containing:
my-project/
├── client/
│ ├── package.json
│ └── src/
│
└── server/
├── package.json
└── src/where the client uses Vite/React and the server uses Express/PostgreSQL can be detected automatically.
Running:
dockerez generatecan produce:
my-project/
├── client/
│ ├── Dockerfile
│ └── .dockerignore
│
├── server/
│ ├── Dockerfile
│ └── .dockerignore
│
├── docker-compose.yml
└── .env.exampleDocker Compose
For multi-service applications, Dockerez can generate a Compose configuration containing the detected application and database services.
For example:
services:
client:
build:
context: ./client
ports:
- "5173:80"
server:
build:
context: ./server
ports:
- "5000:5000"
postgres:
image: postgres:17
ports:
- "5432:5432"Database services can include:
- Persistent volumes
- Healthchecks
- Environment variables
- Application dependencies
- Internal Docker service names
Service networking
Containers communicate with each other using Docker Compose service names.
For example, PostgreSQL is reachable from another container using:
postgres:5432rather than:
localhost:5432Applications should therefore use environment variables such as:
DATABASE_URLwhen connecting to databases inside Compose.
Environment Variables
When database services are detected, Dockerez can generate:
.env.exampleFor example:
POSTGRES_USER=postgres
POSTGRES_PASSWORD=change_me
POSTGRES_DB=appCopy this file to .env and provide appropriate values before starting the Compose stack.
cp .env.example .envOn Windows PowerShell:
Copy-Item .env.example .envDo not commit .env files containing real credentials.
Package Managers
For Node.js projects, dockerez detects common package managers using their lockfiles.
Supported package managers include:
- npm
- Yarn
- pnpm
For example:
package-lock.json → npm
yarn.lock → Yarn
pnpm-lock.yaml → pnpmPython projects currently support:
- pip
- Poetry
- Pipenv
Generated Dockerfiles
Dockerez uses technology-specific templates.
Vite
Vite applications are built in a Node.js builder stage and served using Nginx.
Node.js
↓
npm run build
↓
Nginx
↓
port 80Express
Express applications are packaged as Node.js containers and started using the project's production start command.
Next.js
Next.js applications are built and started using the Next.js production workflow.
FastAPI
FastAPI applications use a Python container and Uvicorn.
Development vs Production
Dockerez currently generates production-oriented Dockerfiles.
For example, Vite applications are built using:
npm run buildand served by Nginx rather than running the Vite development server.
This means a Compose mapping such as:
ports:
- "5173:80"makes the application available at:
http://localhost:5173while the container itself continues to serve the production build on port 80.
Requirements
Dockerez requires:
- Node.js 18 or newer
Docker and Docker Compose are required when you want to build or run the generated containers.
Check your environment with:
dockerez doctorProject Structure
Dockerez itself is organized around scanning, analysis, configuration, and generation:
dockerez/
├── bin/
│ └── dockerez.js
│
├── src/
│ ├── commands/
│ │ ├── init.js
│ │ ├── generate.js
│ │ ├── clean.js
│ │ └── doctor.js
│ │
│ ├── core/
│ │ ├── analyzer.js
│ │ ├── fileScanner.js
│ │ ├── packageReader.js
│ │ ├── projectScanner.js
│ │ └── fileWriter.js
│ │
│ ├── detectors/
│ │ ├── express.js
│ │ ├── next.js
│ │ ├── vite.js
│ │ ├── react.js
│ │ ├── fastapi.js
│ │ ├── postgres.js
│ │ ├── mongodb.js
│ │ └── redis.js
│ │
│ ├── config/
│ │ ├── projectConfig.js
│ │ ├── nodeConfig.js
│ │ └── pythonConfig.js
│ │
│ └── generators/
│ ├── dockerfile.js
│ ├── dockerignore.js
│ ├── compose.js
│ └── env.js
│
├── templates/
│ ├── express/
│ ├── next/
│ ├── vite/
│ ├── fastapi/
│ └── common/
│
├── bin/
├── package.json
└── README.mdDevelopment
Clone the repository and install dependencies:
npm installDuring development, Dockerez can be linked globally:
npm linkThen:
dockerez --helpAfter making changes to the source code, the linked CLI uses the updated files.
License
MIT
~ By Bhargav Chaudhari
