Tunn8n - N8N + Ngrok Docker Starter
A complete CLI tool to create and manage n8n (workflow automation) with Docker and expose it to the internet using Ngrok with custom domain support.
π Features
- β Easy CLI Setup - Create new projects with one command
- β n8n latest version with Docker Compose
- β Ngrok integration with custom domain support
- β Secure environment variables handling
- β Health checks and auto-restart
- β Persistent data storage
- β Multi-platform support (macOS, Windows, Linux)
- β Complete CLI interface for easy management
- β Automatic script management with proper permissions
- β Environment validation and error checking
- β Fallback mechanisms for robust operation
π¦ Installation
Method 1: Install via npm (Recommended)
# Install globally
npm install -g tunn8n@latest
# Verify installation
tunn8n --version
tunn8n -v
Method 2: Manual Setup (if preferred)
# Clone the repository
git clone https://github.com/ahmadrizal1st/tunn8n.git
cd tunn8n
# Install dependencies(optional)
npm install
# Link for local development
npm link
π Quick Start
1. Create a New Project
# Create new n8n project
tunn8n create my-automation-project
# Navigate to project
cd my-automation-project
2. Initialize Environment
# Setup environment configuration
tunn8n init
# Edit .env file with your settings
nano .env # or use your favorite editor
3. Configure Environment
Edit the .env
file:
# Ngrok Configuration
NGROK_AUTHTOKEN=your_ngrok_auth_token_here
NGROK_DOMAIN=your_custom_domain.ngrok-free.app # Optional for paid plans
# n8n Configuration
N8N_PORT=5678
N8N_PROTOCOL=http
WEBHOOK_URL=your_ngrok_url
TZ=Asia/Jakarta
# Optional: Basic Auth (recommended)
# N8N_BASIC_AUTH_USER=admin
# N8N_BASIC_AUTH_PASSWORD=secure_password_here
β οΈ IMPORTANT: Get your Ngrok auth token from Ngrok Dashboard
4. Start Services
# Start n8n with Ngrok tunnel
tunn8n start
π οΈ CLI Commands
Project Management
# Create new project
tunn8n create <project-name>
# Initialize environment (create .env from template)
tunn8n init
# Update to latest version
tunn8n update
Service Control
# Start all services
tunn8n start
# Check service status
tunn8n status
# View debug information and logs
tunn8n debug
# Stop all services
tunn8n stop
Information
# Show version
tunn8n --version
tunn8n -v
# Show help
tunn8n --help
π Prerequisites
Required Software
- Docker - Install Guide
- Docker Compose - Usually included with Docker Desktop
- Node.js (v14+) - Only required for CLI tool
Ngrok Setup
- Create free account at ngrok.com
- Get your auth token from dashboard
- (Optional) Reserve custom domain for paid plans
π§ Project Structure
my-automation-project/
βββ docker-compose.yml # Docker compose configuration
βββ .env # Environment variables (created by tunn8n init)
βββ .env.example # Environment template and dependencies
βββ .gitignore # Git ignore rules
βββ package.json # Project metadata
βββ README.md # Project documentation
π Access Points
After starting services:
- Local n8n Access: http://localhost:5678
- Remote Access: Your Ngrok URL (shown in logs)
- Ngrok Dashboard: http://localhost:4040
π Monitoring
Check Service Status
tunn8n status
# Or manually
docker-compose ps
docker stats
View Logs
tunn8n debug
# Or follow specific logs
docker-compose logs -f n8n-app
docker-compose logs -f n8n-ngrok
π Stopping Services
Graceful Shutdown
# Using CLI
tunn8n stop
# Using Docker directly
docker-compose down
Complete Cleanup
# Remove everything (including volumes)
docker-compose down -v
# Clean Docker system
docker system prune -f
π Troubleshooting
Common Issues
Port 5678 already in use
# Change N8N_PORT in .env file N8N_PORT=5679
Ngrok authentication errors
- Verify
NGROK_AUTHTOKEN
in.env
file - Check token at Ngrok Dashboard
- Verify
Docker permission issues (Linux)
sudo usermod -aG docker $USER newgrp docker
Script permission issues
# Grant execute permissions to scripts chmod +x bin/scripts/*.js
Debug Commands
# Check Ngrok tunnel status
docker exec n8n-ngrok curl -s http://localhost:4040/api/tunnels | jq
# Test n8n health
curl http://localhost:5678/healthz
# View container logs
docker logs n8n-app --tail 50
π Security Notes
- Never commit
.env
file to version control - Use strong passwords for basic authentication
- Regularly rotate Ngrok authentication tokens
- Monitor access logs frequently
- Consider VPN for production use
π Support
Useful Links
Getting Help
- Check logs:
tunn8n debug
- Verify Ngrok token is correct
- Ensure Docker is running
- Check port availability
- Validate environment variables:
tunn8n init
and check.env
file
π― Example Usage
# Complete workflow example
tunn8n create my-n8n-project
cd my-n8n-project
tunn8n init
# Edit .env with your Ngrok token and settings
nano .env
tunn8n start
tunn8n status
# When done working
tunn8n stop
π License
MIT License - feel free to use this project for your automation needs!
Happy Automating! π
For issues and contributions, please check the project repository.
π Changelog
Version 1.3.12
- Enhanced CLI with better error handling and fallback mechanisms
- Automatic script permissions management
- Environment validation with helpful warnings
- Improved project structure with dedicated scripts directory
- Better Docker compatibility checks
- Template-based .env initialization
- Comprehensive .gitignore for security
Key Improvements
- β Automatic script permission setting (chmod 755)
- β Environment variable validation with warnings
- β Fallback to direct docker commands if scripts fail
- β Better error messages and user guidance
- β Template-based project creation with proper structure
- β Enhanced security with comprehensive .gitignore
Note: This tool automatically handles script permissions and provides fallback mechanisms for robust operation across different environments.