Skip to content

A powerful Node.js CLI tool that automates the complete deployment setup for Dokploy. Deploy your applications from local development to live, production-ready environments with custom domains, SSL certificates, and environment variables in just one command.

License

Notifications You must be signed in to change notification settings

JoshuaRileyDev/dokploy-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Dokploy Deploy CLI

A powerful Node.js CLI tool that automates the complete deployment setup for Dokploy. Deploy your applications from local development to live, production-ready environments with custom domains, SSL certificates, and environment variables in just one command.

npm version License: MIT

✨ Features

  • πŸ”„ Automatic Repository Management - Creates GitHub repositories if needed
  • πŸ—οΈ Intelligent Project Detection - Supports both single applications and monorepos
  • 🌐 Custom Domain Setup - Automatic domain creation with Let's Encrypt SSL
  • πŸ”§ Environment Variable Configuration - Detects and configures .env, .env.local, and .env.example files
  • πŸš€ One-Command Deployment - Complete setup and deployment in a single command
  • πŸ“¦ Monorepo Support - Detects and deploys multiple applications from monorepo structures
  • πŸ”’ Secure by Default - HTTPS enabled with automatic SSL certificate management
  • πŸ“ Comprehensive Logging - Detailed verbose mode for debugging

πŸ› οΈ Installation

Global Installation (Recommended)

npm install -g @joshuarileydev/dokploy-deploy

Local Installation

npm install --save-dev @joshuarileydev/dokploy-deploy

Using npx (No Installation Required)

npx @joshuarileydev/dokploy-deploy

πŸ“‹ Prerequisites

  1. Dokploy Instance - A running Dokploy server with API access
  2. GitHub CLI - Install from cli.github.com
  3. Git Repository - Initialize your project with git (or let the CLI do it)
  4. Environment Variables - Set up your Dokploy credentials

βš™οΈ Configuration

Required Environment Variables

Create a .env file in your project root or set these environment variables:

# Your Dokploy instance URL
DOKPLOY_URL=https://your-dokploy-instance.com

# Your Dokploy API key (get this from your Dokploy dashboard)
DOKPLOY_API_KEY=your-dokploy-api-token

# Your wildcard domain for applications (required)
DOKPLOY_DOMAIN=your-custom-domain.com

GitHub CLI Setup

Authenticate with GitHub CLI:

gh auth login

πŸš€ Usage

Basic Usage

Navigate to your project directory and run:

dokploy-deploy

Verbose Mode (Recommended for debugging)

dokploy-deploy --verbose

Help

dokploy-deploy --help

πŸ“ Project Structure Support

Single Application

For a standard single application:

my-app/
β”œβ”€β”€ package.json
β”œβ”€β”€ .env                    # Environment variables (optional)
β”œβ”€β”€ .env.local             # Local environment variables (optional)
β”œβ”€β”€ .env.example           # Example environment variables (optional)
β”œβ”€β”€ src/
└── ...

Result: Application deployed at https://my-app.your-domain.com (customize with DOKPLOY_DOMAIN)

Monorepo Structure

For monorepo projects, the CLI automatically detects applications in common directories:

my-monorepo/
β”œβ”€β”€ package.json
β”œβ”€β”€ .env                   # Shared environment variables (optional)
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   β”œβ”€β”€ .env           # API-specific environment variables
β”‚   β”‚   └── src/
β”‚   └── web/
β”‚       β”œβ”€β”€ package.json
β”‚       β”œβ”€β”€ .env.local     # Web-specific environment variables
β”‚       └── src/
β”œβ”€β”€ packages/              # Also supported
└── libs/                  # Also supported

Result:

  • API: https://my-monorepo-api.your-domain.com
  • Web: https://my-monorepo-web.your-domain.com

Supported Monorepo Directories

The CLI automatically detects applications in these directories:

  • packages/
  • apps/
  • projects/
  • modules/
  • libs/
  • services/
  • components/
  • workspaces/
  • sites/

🌍 Environment Variables

Detection Priority

The CLI looks for environment files in this order:

  1. .env - Main environment file
  2. .env.local - Local environment overrides
  3. .env.example - Example/template file

Monorepo Environment Detection

For monorepos, the CLI:

  1. First - Looks for environment files in each app's directory (apps/api/.env)
  2. Fallback - Uses root directory environment files for shared variables

Example Environment Files

.env

DATABASE_URL=postgresql://user:password@localhost:5432/mydb
API_KEY=your-api-key-here
NODE_ENV=production
PORT=3000
JWT_SECRET=your-jwt-secret-here

apps/web/.env.local

REACT_APP_API_URL=https://my-app-api.your-domain.com
REACT_APP_TITLE=My Amazing App
REACT_APP_VERSION=1.0.0

πŸ—οΈ What the CLI Does

Complete Automated Setup

  1. πŸ” Repository Detection - Checks for existing Git repository
  2. πŸ“¦ GitHub Repository Creation - Creates repository if none exists
  3. πŸ”Ž Project Analysis - Detects single app vs monorepo structure
  4. πŸ—οΈ Dokploy Project Creation - Sets up project in Dokploy
  5. βš™οΈ Server Configuration - Configures server and GitHub integration
  6. πŸš€ Application Creation - Creates applications for each detected app
  7. πŸ”— Repository Configuration - Links GitHub repository with build paths
  8. 🌐 Domain Setup - Creates custom domains with SSL certificates
  9. πŸ”§ Environment Configuration - Uploads environment variables
  10. πŸš€ Deployment - Initiates application deployments

Domain Configuration

  • Port: 3000
  • SSL: Let's Encrypt (automatic)
  • Protocol: HTTPS (enforced)
  • Path: / (root)
  • Custom Domain: Set DOKPLOY_DOMAIN=your-domain.com to use your own wildcard domain
  • Required: You must configure DOKPLOY_DOMAIN environment variable for your deployments

🎯 Examples

Deploy a Next.js App

# In your Next.js project directory
npm install -g @joshuarileydev/dokploy-deploy
dokploy-deploy

Deploy a Monorepo with API and Frontend

# Project structure:
# my-project/
# β”œβ”€β”€ apps/
# β”‚   β”œβ”€β”€ api/     (Node.js/Express API)
# β”‚   └── web/     (React/Next.js frontend)

dokploy-deploy --verbose

Deploy with Custom Environment Variables

# Create .env file
echo "DATABASE_URL=postgresql://user:pass@localhost:5432/db" > .env
echo "API_KEY=your-secret-key" >> .env

# Deploy
dokploy-deploy

Deploy with Custom Domain

# Set custom domain
export DOKPLOY_DOMAIN=myapps.example.com

# Deploy (apps will be available at myapp.myapps.example.com)
dokploy-deploy

πŸ“Š Example Output

Single Application

πŸš€ Dokploy Deploy CLI
Working in: /path/to/my-app
Project name: my-app

βœ“ Using Dokploy instance: https://dokploy.example.com
βœ” GitHub repository created: https://github.com/user/my-app
βœ” Single application repository detected
βœ” Dokploy project created: my-app
βœ” Application "app" created, configured, and deployed successfully

βœ… Deployment setup complete!
Application configured with:
- Repository: https://github.com/user/my-app
- Build path: . (root directory)
- Branch: main
- Domain: https://my-app.your-domain.com
- Port: 3000
- SSL: Let's Encrypt

🌐 Your application will be available at: https://my-app.your-domain.com

Monorepo

πŸš€ Dokploy Deploy CLI
Working in: /path/to/my-monorepo
Project name: my-monorepo

πŸ” Detailed monorepo detection:
πŸ“ Checking directory structures:
  Checking: apps/
    βœ“ Found 2 potential applications:
      - api/ (package.json)
      - web/ (package.json)

πŸš€ Applications that will be deployed:
  1. api β†’ apps/api/
  2. web β†’ apps/web/

βœ“ Environment variables configured for api from .env
βœ“ Environment variables configured for web from .env.local

βœ… Deployment setup complete!
Created applications:
  - api β†’ apps/api/
    🌐 https://my-monorepo-api.your-domain.com
  - web β†’ apps/web/
    🌐 https://my-monorepo-web.your-domain.com

πŸš€ Your applications are being deployed and will be available at the URLs above!

πŸ”§ Troubleshooting

Common Issues

❌ "DOKPLOY_URL environment variable is required"

# Solution: Set your Dokploy instance URL
export DOKPLOY_URL=https://your-dokploy-instance.com

❌ "GitHub CLI not authenticated"

# Solution: Authenticate with GitHub
gh auth login

❌ "No GitHub integration found"

# Solution: Set up GitHub App integration in your Dokploy dashboard
# The CLI will provide instructions for manual configuration

❌ "Not a git repository"

# Solution: Initialize git repository
git init
# Or let the CLI do it automatically

Debug Mode

Use verbose mode for detailed logging:

dokploy-deploy --verbose

This shows:

  • API requests and responses
  • File detection results
  • Environment variable parsing
  • Detailed error messages

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development

# Clone the repository
git clone https://github.com/JoshuaRileyDev/dokploy-deploy.git
cd dokploy-deploy

# Install dependencies
npm install

# Test locally
npm link
dokploy-deploy --help

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Dokploy - The amazing deployment platform
  • GitHub CLI - For seamless GitHub integration
  • Commander.js - For CLI argument parsing
  • Axios - For HTTP requests
  • Chalk - For beautiful terminal colors
  • Ora - For elegant terminal spinners

πŸ“ž Support


Made with ❀️ by Joshua Riley

About

A powerful Node.js CLI tool that automates the complete deployment setup for Dokploy. Deploy your applications from local development to live, production-ready environments with custom domains, SSL certificates, and environment variables in just one command.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •