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.
- β 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
# Install globally or from the latest GitHub version
npm install -g tun8n@latest
npm install github:ahmadrizal1st/tun8n
# Verify installation
tun8n --version
tun8n -v
# Clone the repository
git clone https://github.com/ahmadrizal1st/tun8n.git
cd tun8n
# Install dependencies(optional)
npm install
# Link for local development
npm link
# Create new n8n project
tun8n create my-automation-project
# Navigate to project
cd my-automation-project
# Setup environment configuration
tun8n init
# Edit .env file with your settings
nano .env # or use your favorite editor
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
# Start n8n with Ngrok tunnel
tun8n start
# Create new project
tun8n create <project-name>
# Initialize environment (create .env from template)
tun8n init
# Update to latest version
tun8n update
# Start all services
tun8n start
# Check service status
tun8n status
# View debug information and logs
tun8n debug
# Stop all services
tun8n stop
# Show version
tun8n --version
tun8n -v
# Show help
tun8n --help
- Docker - Install Guide
- Docker Compose - Usually included with Docker Desktop
- Node.js (v14+) - Only required for CLI tool
- Create free account at ngrok.com
- Get your auth token from dashboard
- (Optional) Reserve custom domain for paid plans
my-automation-project/
βββ docker-compose.yml # Docker compose configuration
βββ .env # Environment variables (created by tun8n init)
βββ .env.example # Environment template and dependencies
βββ .gitignore # Git ignore rules
βββ package.json # Project metadata
βββ README.md # Project documentation
After starting services:
- Local n8n Access: http://localhost:5678
- Remote Access: Your Ngrok URL (shown in logs)
- Ngrok Dashboard: http://localhost:4040
tun8n status
# Or manually
docker-compose ps
docker stats
tun8n debug
# Or follow specific logs
docker-compose logs -f n8n-app
docker-compose logs -f n8n-ngrok
# Using CLI
tun8n stop
# Using Docker directly
docker-compose down
# Remove everything (including volumes)
docker-compose down -v
# Clean Docker system
docker system prune -f
-
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
# 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
- 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
- Check logs:
tun8n debug
- Verify Ngrok token is correct
- Ensure Docker is running
- Check port availability
- Validate environment variables:
tun8n init
and check.env
file
# Complete workflow example
tun8n create my-n8n-project
cd my-n8n-project
tun8n init
# Edit .env with your Ngrok token and settings
nano .env
tun8n start
tun8n status
# When done working
tun8n stop
MIT License - feel free to use this project for your automation needs!
Happy Automating! π
For issues and contributions, please check the project repository.
- 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
- β 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.