Skip to content
el-noirPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

RepDev πŸš€

Reproducible Development Environments Made Simple

A lightweight CLI tool that makes setting up development environments as easy as running a single command. No more "it works on my machine" - RepDev ensures consistent environments across your entire team using Docker containers with intelligent orchestration.

Node.js Docker License PRs Welcome


✨ Features

  • 🎯 One Command Setup - repdev up starts your entire stack
  • πŸ“¦ Pre-built Presets - MERN, Django, Next.js, and more
  • 🎨 Interactive CLI - Guided setup with smart prompts
  • πŸ”„ Lifecycle Hooks - Run scripts before/after container events
  • ⏱️ Readiness Checks - Wait for services to be truly ready
  • πŸ” Environment Files - Secure .env file support
  • 🌐 Network Control - Host, bridge, and custom networks
  • πŸ› οΈ DX Commands - logs, exec, restart without leaving RepDev
  • πŸ₯ Health Checks - repdev doctor diagnoses issues
  • πŸ“Š State Tracking - Know what's running and when

πŸš€ Quick Start

Installation

npm install -g repdev

Create Your First Project

# List available presets
repdev init --list

# Initialize with a preset (interactive prompts)
repdev init -p mern

# Start your environment
repdev up

# Check status
repdev status

# View logs
repdev logs backend -f

# Stop everything
repdev down

πŸ“‹ Table of Contents


πŸ’‘ Why RepDev?

The Problem

Setting up development environments is painful:

  • ❌ Complex Docker Compose files
  • ❌ Manual dependency installation
  • ❌ Different environments across team members
  • ❌ "Works on my machine" syndrome
  • ❌ No standardized onboarding process

The Solution

RepDev provides:

  • βœ… Simple YAML templates
  • βœ… Interactive setup wizards
  • βœ… Consistent environments everywhere
  • βœ… Automated health checks
  • βœ… New developers productive in minutes

Comparison

Feature Docker Compose RepDev
Syntax Verbose YAML Simple YAML
Setup Manual Interactive prompts
Hooks Limited Full lifecycle
Readiness Depends on Built-in wait_for
Presets None MERN, Django, etc.
Port Checks No Automatic
Error Help Generic Actionable suggestions
State Tracking No Yes

πŸ“₯ Installation

Prerequisites

Install RepDev

# Global installation
npm install -g repdev

# Verify installation
repdev --version

# Check system health
repdev doctor

🎯 Available Presets

RepDev comes with battle-tested presets for popular stacks:

🟒 MERN Stack

repdev init -p mern
  • Frontend: React (Vite)
  • Backend: Node.js + Express
  • Database: MongoDB Atlas
  • Features: Hot reload, auto-install deps, interactive network configuration

🐍 Django

repdev init -p django
  • Framework: Django
  • Database: PostgreSQL
  • Features: Auto migrations, static files, custom network support

πŸ”₯ Django REST + React

repdev init -p django-drf
  • Backend: Django REST Framework
  • Frontend: React
  • Database: PostgreSQL
  • Features: Full API setup, network isolation options

🌐 Network Demo

repdev init -p network-demo
  • Purpose: Multi-tier network architecture demonstration
  • Services: 7 containers with 3 isolated networks
  • Features: Shows microservices, host mode, static IPs, sidecars

πŸ–₯️ CLI Commands

Core Commands

repdev init

Create a new repdev.yml template.

# Interactive mode
repdev init

# Use a preset
repdev init -p mern

# List available presets
repdev init --list

# Force overwrite existing file
repdev init -p django --force

repdev up

Start your development environment.

# Start all services
repdev up

# Use specific template
repdev up -t custom-template.yml

# Use preset
repdev up -p mern

# Force recreate containers
repdev up --force

# Skip readiness checks
repdev up --no-wait

# Start specific services
repdev up -s backend,db

repdev down

Stop and remove containers.

# Stop all services
repdev down

# Stop specific services
repdev down -s frontend

# Force removal
repdev down --force

repdev status

Check environment status.

repdev status

Output:

πŸ“Š RepDev Status

Template: /path/to/repdev.yml
Preset: mern

Containers: 2 total, 2 running, 0 stopped
Last Up: 10/20/2025, 2:30:15 PM

πŸ“¦ Containers:

🟒 backend (mern_backend)
   Image: node:20
   Status: running
   Ports: 3000:3000

🟒 frontend (mern_frontend)
   Image: node:20
   Status: running
   Ports: 5173:5173

DX Commands

repdev logs <service>

View container logs.

# View logs
repdev logs backend

# Follow logs (like tail -f)
repdev logs backend -f

# Show last 50 lines
repdev logs backend --tail 50

repdev exec <service> [command...]

Execute commands in containers.

# Interactive shell
repdev exec backend bash

# Run a command
repdev exec backend npm run test

# Database access
repdev exec db psql -U postgres mydb

repdev restart [service]

Restart containers.

# Restart a service
repdev restart backend

# Restart all services
repdev restart --all

Utility Commands

repdev validate

Validate template syntax.

# Validate local repdev.yml
repdev validate

# Validate specific file
repdev validate -t custom.yml

# Validate preset
repdev validate -p mern

repdev doctor

Run system health checks.

# Basic health check
repdev doctor

# Include port availability
repdev doctor --ports

Output:

πŸ₯ RepDev System Health Check

🟒 Node.js
   Status: βœ… OK
   Version: v20.10.0

🐳 Docker
   Status: βœ… OK
   Version: 24.0.6

πŸ“„ Template (repdev.yml)
   Status: βœ… OK

πŸ’Ύ Disk Space
   Status: βœ… OK

πŸ“¦ RepDev Containers
   Status: βœ… OK
   Total: 2 (2 running, 0 stopped)

✨ All systems operational!

πŸ“ Template Structure

Basic Template

version: '1.0'

metadata:
  name: my-app
  description: My awesome application
  author: Your Name

services:
  app:
    image: node:20-alpine
    container_name: my_app
    working_dir: /app
    volumes:
      - ./app:/app
    ports:
      - "3000:3000"
    environment:
      NODE_ENV: development
      PORT: 3000
    command:
      - sh
      - -c
      - |
        npm install
        npm run dev

Advanced Template

version: '1.0'

metadata:
  name: advanced-app

hooks:
  preUp:
    - echo "πŸš€ Starting environment..."
  postUp:
    - echo "βœ… Environment ready!"
    - 'echo "🌐 Visit: http://localhost:3000"'
  preDown:
    - echo "🧹 Cleaning up..."
  postDown:
    - echo "βœ… Cleanup complete"

services:
  backend:
    image: node:20
    container_name: app_backend
    working_dir: /app
    volumes:
      - ./backend:/app
    ports:
      - "3000:3000"
    env_file:
      - ./backend/.env
    environment:
      NODE_ENV: development
    hooks:
      beforeStart:
        - echo "Installing backend dependencies..."
      afterStart:
        - echo "Backend started!"
    wait_for:
      type: http
      url: http://localhost:3000/health
      timeout: 60000
      retries: 30
      interval: 2000
    command:
      - sh
      - -c
      - |
        npm install
        npm run dev
    depends_on:
      - db

  db:
    image: postgres:15-alpine
    container_name: app_db
    environment:
      POSTGRES_USER: devuser
      POSTGRES_PASSWORD: devpass
      POSTGRES_DB: devdb
    ports:
      - "5432:5432"
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    wait_for:
      type: tcp
      host: localhost
      port: 5432

πŸ”§ Advanced Features

Lifecycle Hooks

Execute scripts at specific points in the container lifecycle:

hooks:
  preUp: ["echo Starting..."]
  postUp: ["echo Ready!"]
  preDown: ["echo Stopping..."]
  postDown: ["echo Stopped"]

services:
  app:
    hooks:
      beforeStart: ["npm install"]
      afterStart: ["npm run migrate"]

Readiness Checks

Wait for services to be truly ready:

services:
  api:
    wait_for:
      type: http
      url: http://localhost:3000/health
      timeout: 60000
      retries: 30
      interval: 2000

  db:
    wait_for:
      type: tcp
      host: localhost
      port: 5432

  container:
    wait_for:
      type: container_healthy

Environment Files

Keep secrets out of version control:

services:
  app:
    env_file:
      - .env              # Base config
      - .env.local        # Local overrides
    environment:
      NODE_ENV: development  # Overrides .env

Priority: inline environment > env_file

Network Configuration

Control container networking for isolation, performance, and multi-tier architectures:

Network Modes:

services:
  app:
    network_mode: host    # High performance, uses host network
    # network_mode: bridge  # Default, isolated networking
    # network_mode: none    # No networking

Custom Networks (recommended for complex apps):

networks:
  frontend:
  backend:
  database:

services:
  web:
    networks: [frontend]
  api:
    networks: [frontend, backend]
  db:
    networks: [database]  # Fully isolated

Advanced Network Config:

networks:
  app_net:
    driver: bridge
    ipam:
      config:
        - subnet: 172.25.0.0/16

services:
  api:
    networks:
      app_net:
        ipv4_address: 172.25.0.10
        aliases: [api-server, backend]

πŸ“– Full Guide: docs/NETWORK_CONFIGURATION.md


🎨 Customization

See CUSTOMIZATION.md for detailed customization guide.

Quick Tips

Change directories:

volumes:
  - ./backend:/app  # Change to ./server:/app

Change ports:

ports:
  - "3000:3000"  # Change to "4000:4000"

Change package manager:

command:
  - npm install   # Change to 'yarn install' or 'pnpm install'

Use environment files:

env_file:
  - .env

πŸ› Troubleshooting

Docker Not Running

Error: Cannot connect to the Docker daemon

Solutions:

  1. Start Docker Desktop
  2. Check if Docker daemon is running: docker ps
  3. On Linux: sudo systemctl start docker

Port Already in Use

Error: EADDRINUSE: address already in use

Solutions:

  1. Find the process: netstat -ano | findstr :<port> (Windows)
  2. Stop conflicting containers: repdev down
  3. Change the port in repdev.yml
  4. Kill the process or use a different port

Container Name Conflict

Error: container name already in use

Solutions:

  1. Use --force flag: repdev up --force
  2. Stop existing containers: repdev down
  3. Remove conflicting container: docker rm -f <name>

Image Not Found

Error: pull access denied or not found

Solutions:

  1. Check image name spelling in repdev.yml
  2. Verify image exists on Docker Hub
  3. Try pulling manually: docker pull <image>
  4. Login if needed: docker login

Template Not Found

Error: no such file or directory: repdev.yml

Solutions:

  1. Run repdev init to create a template
  2. Use -t flag: repdev up -t /path/to/template.yml
  3. Use a preset: repdev up -p mern

Permission Denied

Error: permission denied

Solutions:

  1. On Linux: sudo usermod -aG docker $USER
  2. On Windows: Run as Administrator
  3. Check file/directory permissions

πŸ₯ Health Checks

Run diagnostic checks:

repdev doctor

This checks:

  • βœ… Node.js version
  • βœ… Docker connectivity
  • βœ… Template validity
  • βœ… Disk space
  • βœ… Container status

With port check:

repdev doctor --ports

πŸ—οΈ Architecture

repdev/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli/
β”‚   β”‚   └── commands/      # CLI command implementations
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ dockerManager.js    # Docker orchestration
β”‚   β”‚   β”œβ”€β”€ TemplateManager.js  # Template loading
β”‚   β”‚   β”œβ”€β”€ HooksRunner.js      # Lifecycle hooks
β”‚   β”‚   └── logger.js           # Logging
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ envFileLoader.js    # .env file parsing
β”‚   β”‚   β”œβ”€β”€ errorHandler.js     # Error handling
β”‚   β”‚   └── stateManager.js     # State tracking
β”‚   └── templates/
β”‚       └── presets/       # Pre-built templates
└── docs/                  # Documentation

🀝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Quick Start for Contributors

# Clone the repo
git clone https://github.com/el-noir/repdev.git
cd repdev

# Install dependencies
npm install

# Test locally
node src/index.js --help

# Run tests
npm test

πŸ“œ License

MIT Β© el-noir


πŸ™ Acknowledgments

Built with:


πŸ“š Resources


⭐ Star History

If RepDev helped you, please give it a ⭐ on GitHub!


Made with ❀️ by developers, for developers

Report Bug Β· Request Feature Β· Documentation

About

No description, website, or topics provided.

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages