159 lines
4.4 KiB
Markdown
159 lines
4.4 KiB
Markdown
|
|
# Seclore n8n Development Container
|
||
|
|
|
||
|
|
This devcontainer provides a complete development environment for the Seclore n8n custom node project.
|
||
|
|
|
||
|
|
## 🚀 Quick Start
|
||
|
|
|
||
|
|
1. **Open in Container**:
|
||
|
|
- Open this project in VS Code
|
||
|
|
- Click "Reopen in Container" when prompted
|
||
|
|
- Or use Command Palette: `Dev Containers: Reopen in Container`
|
||
|
|
|
||
|
|
2. **Wait for Setup**:
|
||
|
|
- The container will automatically install dependencies
|
||
|
|
- This may take a few minutes on first run
|
||
|
|
|
||
|
|
3. **Start Development**:
|
||
|
|
```bash
|
||
|
|
start_dev # Build and start n8n with custom nodes
|
||
|
|
```
|
||
|
|
|
||
|
|
4. **Access n8n**:
|
||
|
|
- Open http://localhost:5678 in your browser
|
||
|
|
- Your custom Seclore Protect node will be available
|
||
|
|
|
||
|
|
## 📦 What's Included
|
||
|
|
|
||
|
|
### Software
|
||
|
|
- **Node.js 20.x** - Latest LTS version
|
||
|
|
- **npm** - Latest version
|
||
|
|
- **n8n** - Latest version (globally installed)
|
||
|
|
- **TypeScript** - For development
|
||
|
|
- **ts-node** - TypeScript execution
|
||
|
|
- **nodemon** - Auto-restart on changes
|
||
|
|
|
||
|
|
### VS Code Extensions
|
||
|
|
- **TypeScript & JavaScript**: Enhanced language support
|
||
|
|
- **ESLint & Prettier**: Code formatting and linting
|
||
|
|
- **Node.js IntelliSense**: Smart completions for Node.js
|
||
|
|
- **npm IntelliSense**: Package import suggestions
|
||
|
|
- **Git Tools**: GitLens and Git Graph
|
||
|
|
- **REST Client**: API testing tools
|
||
|
|
- **Docker**: Container management
|
||
|
|
|
||
|
|
### Development Tools
|
||
|
|
- **build_and_test**: Build project and run linter
|
||
|
|
- **start_dev**: Build and start n8n with custom nodes
|
||
|
|
- **watch_build**: Auto-rebuild on file changes
|
||
|
|
- **~/start-n8n.sh**: Direct n8n startup script
|
||
|
|
|
||
|
|
## 🔧 Development Workflow
|
||
|
|
|
||
|
|
### 1. Make Changes
|
||
|
|
Edit your TypeScript files in:
|
||
|
|
- `nodes/SecloreProtect/` - Main node logic
|
||
|
|
- `Services/` - API service classes
|
||
|
|
- `credentials/` - Credential definitions
|
||
|
|
|
||
|
|
### 2. Build & Test
|
||
|
|
```bash
|
||
|
|
build_and_test # Compile TypeScript and run linter
|
||
|
|
```
|
||
|
|
|
||
|
|
### 3. Start n8n
|
||
|
|
```bash
|
||
|
|
start_dev # Build and start n8n
|
||
|
|
# OR
|
||
|
|
~/start-n8n.sh # Start n8n directly (after manual build)
|
||
|
|
```
|
||
|
|
|
||
|
|
### 4. Auto-rebuild (Optional)
|
||
|
|
```bash
|
||
|
|
watch_build # Watch for changes and auto-rebuild
|
||
|
|
```
|
||
|
|
|
||
|
|
## 🌐 Port Forwarding
|
||
|
|
|
||
|
|
The container automatically forwards these ports:
|
||
|
|
- **5678**: n8n web interface
|
||
|
|
- **3000**: Development server
|
||
|
|
- **8080**: Alternative port
|
||
|
|
|
||
|
|
## 📁 Volume Mounts
|
||
|
|
|
||
|
|
- **Project Files**: `/workspaces/Seclore n8n` (your source code)
|
||
|
|
- **n8n Data**: `~/.n8n` (n8n configuration and data)
|
||
|
|
- **Node Modules**: Cached for faster rebuilds
|
||
|
|
|
||
|
|
## 🔐 Environment Variables
|
||
|
|
|
||
|
|
The container sets up these environment variables:
|
||
|
|
```bash
|
||
|
|
N8N_HOST=0.0.0.0
|
||
|
|
N8N_PORT=5678
|
||
|
|
N8N_PROTOCOL=http
|
||
|
|
NODE_ENV=development
|
||
|
|
N8N_LOG_LEVEL=debug
|
||
|
|
N8N_CUSTOM_EXTENSIONS=/workspaces/Seclore n8n
|
||
|
|
```
|
||
|
|
|
||
|
|
## 🛠️ Customization
|
||
|
|
|
||
|
|
### Adding Extensions
|
||
|
|
Edit `.devcontainer/devcontainer.json` and add extension IDs to the `extensions` array.
|
||
|
|
|
||
|
|
### Changing Ports
|
||
|
|
Modify the `forwardPorts` array in `devcontainer.json`.
|
||
|
|
|
||
|
|
### Additional Software
|
||
|
|
Add installation commands to `.devcontainer/post-create.sh`.
|
||
|
|
|
||
|
|
## 🐛 Troubleshooting
|
||
|
|
|
||
|
|
### Container Won't Start
|
||
|
|
- Check Docker is running
|
||
|
|
- Ensure you have enough disk space
|
||
|
|
- Try rebuilding: `Dev Containers: Rebuild Container`
|
||
|
|
|
||
|
|
### n8n Won't Start
|
||
|
|
- Check if port 5678 is available
|
||
|
|
- Verify the build completed successfully
|
||
|
|
- Check logs for error messages
|
||
|
|
|
||
|
|
### Build Errors
|
||
|
|
- Run `npm install` to ensure dependencies are installed
|
||
|
|
- Check TypeScript compilation errors
|
||
|
|
- Verify all import paths are correct
|
||
|
|
|
||
|
|
### Custom Node Not Visible
|
||
|
|
- Ensure the build completed successfully
|
||
|
|
- Check that `N8N_CUSTOM_EXTENSIONS` points to the correct path
|
||
|
|
- Restart n8n after making changes
|
||
|
|
|
||
|
|
## 📚 Useful Commands
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Development
|
||
|
|
npm run build # Build the project
|
||
|
|
npm run lint # Run ESLint
|
||
|
|
npm run lint:fix # Fix ESLint issues
|
||
|
|
|
||
|
|
# n8n
|
||
|
|
n8n start # Start n8n manually
|
||
|
|
n8n --help # n8n help
|
||
|
|
|
||
|
|
# Container
|
||
|
|
cat ~/welcome.txt # Show welcome message
|
||
|
|
source ~/dev-scripts.sh # Reload development functions
|
||
|
|
```
|
||
|
|
|
||
|
|
## 🎯 Tips
|
||
|
|
|
||
|
|
1. **Use the integrated terminal** in VS Code for the best experience
|
||
|
|
2. **Enable auto-save** in VS Code for faster development cycles
|
||
|
|
3. **Use the REST Client extension** to test your APIs
|
||
|
|
4. **Check the n8n logs** in the terminal for debugging
|
||
|
|
5. **Use `watch_build`** during active development for auto-rebuilds
|
||
|
|
|
||
|
|
Happy coding! 🚀
|