Skip to main content
Node Blueprint CLI includes optional development and deployment features to enhance your workflow.

Available Features

Currently, the CLI supports Docker containerization. Additional features like ESLint, Prettier, Jest, and GitHub Actions are defined in the codebase but not yet fully implemented in the interactive prompts.

Docker

Multi-stage Dockerfile and docker-compose setup for development and production

ESLint

Coming soon - Code linting and quality checks

Prettier

Coming soon - Automated code formatting

Jest

Coming soon - Testing framework setup

GitHub Actions

Coming soon - CI/CD workflow automation

Docker

When you enable Docker, the CLI generates a production-optimized multi-stage Dockerfile and a complete docker-compose.yml configuration.

Features

  • Multi-stage build - Separate stages for dependencies, development, build, and production
  • Database services - Automatic configuration for PostgreSQL, MySQL, or MongoDB
  • Health checks - Built-in health monitoring for all services
  • Volume management - Persistent data storage for databases
  • Development mode - Hot reload with tsx watch
  • Production optimization - Minimal runtime image with non-root user

Generated Files

├── Dockerfile          # Multi-stage production Dockerfile
├── docker-compose.yml  # Complete service orchestration
└── .dockerignore       # Files excluded from Docker context

Dockerfile Structure

The generated Dockerfile includes four optimized stages: Stage 1: Dependencies
FROM node:18-alpine AS deps
WORKDIR /app

ENV NPM_CONFIG_LOGLEVEL=warn
ENV NPM_CONFIG_UPDATE_NOTIFIER=false

COPY package.json package-lock.json ./
RUN npm ci && npm cache clean --force
Stage 2: Development
FROM node:18-alpine AS dev
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

EXPOSE 8000
CMD ["npx", "tsx", "watch", "src/server.ts"]
Stage 3: Builder
FROM node:18-alpine AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npm run build && npm prune --production
Stage 4: Production Runtime
FROM node:18-alpine AS runner
WORKDIR /app

ENV NODE_ENV=production

# Create non-root user
RUN addgroup --system --gid 1001 nodejs && \
    adduser --system --uid 1001 nodeuser

RUN chown -R nodeuser:nodejs /app

COPY --from=builder --chown=nodeuser:nodejs /app/dist /app/dist
COPY --from=builder --chown=nodeuser:nodejs /app/node_modules /app/node_modules
COPY --from=builder --chown=nodeuser:nodejs /app/package.json /app/package.json

EXPOSE 8000

USER nodeuser

HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
    CMD wget --no-verbose --tries=1 --spider http://localhost:8000/health/app || exit 1

CMD ["node", "dist/src/server.js"]
# Stage 1: Dependencies
FROM node:18-alpine AS deps
WORKDIR /app

ENV NPM_CONFIG_LOGLEVEL=warn
ENV NPM_CONFIG_UPDATE_NOTIFIER=false

COPY package.json package-lock.json ./
RUN npm ci && npm cache clean --force

# Stage 2: Development
FROM node:18-alpine AS dev
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

EXPOSE 8000
CMD ["npx", "tsx", "watch", "src/server.ts"]

# Stage 3: Build
FROM node:18-alpine AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npm run build && npm prune --production

# Stage 4: Runtime
FROM node:18-alpine AS runner
WORKDIR /app

ENV NODE_ENV=production

RUN addgroup --system --gid 1001 nodejs && \
    adduser --system --uid 1001 nodeuser

RUN chown -R nodeuser:nodejs /app

COPY --from=builder --chown=nodeuser:nodejs /app/dist /app/dist
COPY --from=builder --chown=nodeuser:nodejs /app/node_modules /app/node_modules
COPY --from=builder --chown=nodeuser:nodejs /app/package.json /app/package.json

EXPOSE 8000

USER nodeuser

HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
    CMD wget --no-verbose --tries=1 --spider http://localhost:8000/health/app || exit 1

CMD ["node", "dist/src/server.js"]

Docker Compose Configuration

The docker-compose.yml includes your application and selected database:
version: '3.8'

services:
app:
container_name: myapp-app
build:
  context: .
  target: builder
restart: unless-stopped
ports:
  - "8000:8000"
env_file:
  - .env
volumes: 
  - .:/app
  - /app/node_modules
networks:
  - myapp-network
healthcheck:
  test: wget --no-verbose --tries=1 --spider ${HEALTH_CHECK_URL} || exit 1
  interval: 30s
  timeout: 5s
  retries: 3
  start_period: 10s
depends_on:
  postgres:
    condition: service_healthy

postgres:
image: postgres:16-alpine
container_name: myapp-postgres
restart: unless-stopped
ports:
  - "5432:5432"
env_file:
  - .env
volumes:
  - postgres-data:/var/lib/postgresql/data
networks:
  - myapp-network
healthcheck:
  test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
  interval: 10s
  timeout: 5s
  retries: 5

volumes:
postgres-data:

networks: 
myapp-network:
driver: bridge

Docker Commands

Development Mode:
# Start all services
docker-compose up

# Start in background
docker-compose up -d

# View logs
docker-compose logs -f app

# Stop services
docker-compose down

# Stop and remove volumes
docker-compose down -v
Production Build:
# Build production image
docker build --target runner -t myapp:latest .

# Run production container
docker run -p 8000:8000 --env-file .env myapp:latest
Database Management:
# Access PostgreSQL
docker-compose exec postgres psql -U postgres -d myapp

# Access MySQL
docker-compose exec mysql mysql -u root -p myapp

# Access MongoDB
docker-compose exec mongodb mongosh myapp

.dockerignore

The CLI generates a .dockerignore file to exclude unnecessary files:
node_modules
dist
.env
.git
.gitignore
README.md
npm-debug.log
.DS_Store
coverage
.vscode
.idea
*.log

Health Checks

Both the application and database include health checks: Application Health Check:
  • Endpoint: http://localhost:8000/health/app
  • Interval: 30 seconds
  • Timeout: 5 seconds
  • Retries: 3
  • Start period: 5 seconds
Database Health Checks:
  • PostgreSQL: pg_isready command
  • MySQL: mysqladmin ping command
  • MongoDB: mongosh --eval "db.runCommand('ping')"
The CLI generates a health check endpoint:Health Routes (src/routes/health-routes.ts):
import { Router } from "express";
import { getAppHealth } from "../controllers/health-controller.js";

const router = Router();

router.get("/app", getAppHealth);

export default router;
Health Controller (src/controllers/health-controller.ts):
import { Request, Response } from "express";

export const getAppHealth = (req: Request, res: Response) => {
    res.status(200).json({
        success: true,
        message: "Application is healthy",
        timestamp: new Date().toISOString()
    });
};

Coming Soon

The following features are planned for future releases:

ESLint

  • Configured ESLint with TypeScript support
  • Recommended rule sets for Node.js
  • Integration with VS Code
  • Pre-commit hooks

Prettier

  • Automatic code formatting
  • Consistent style across team
  • Integration with ESLint
  • Format on save

Jest

  • Unit testing framework setup
  • TypeScript configuration
  • Coverage reporting
  • Test scripts in package.json

GitHub Actions

  • CI/CD workflow templates
  • Automated testing on push
  • Linting and type checking
  • Deployment workflows
These features are defined in the codebase enums but not yet fully implemented. Check the GitHub repository for updates.

Quick Start

1

Enable Docker

Select Docker when prompted during setup
npx create-node-blueprint my-app
2

Configure environment

Update .env with database credentials
3

Start services

docker-compose up -d
4

Verify health

curl http://localhost:8000/health/app

Best Practices

  • Use docker-compose up for local development
  • Mount source code as volume for hot reload
  • Keep database data in named volumes
  • Use separate .env.development and .env.production
  • Build with --target runner for minimal image
  • Use non-root user (automatically configured)
  • Enable health checks for container orchestration
  • Store secrets in orchestrator (Kubernetes, Docker Swarm)
  • Always use named volumes for persistence
  • Backup volumes before major updates
  • Use health checks to verify database readiness
  • Consider external databases for production

Build docs developers (and LLMs) love