Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions appliances/n8n/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to the n8n appliance will be documented in this file.

## [1.0.0-1] - 2025-10-01

### Added
- Initial release of n8n appliance
- Docker container: n8nio/n8n:latest
- VNC desktop access
- SSH key authentication
- OpenNebula context integration
- Configurable container parameters
82 changes: 82 additions & 0 deletions appliances/n8n/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# n8n Appliance

n8n is a workflow automation tool that allows you to connect different services and automate tasks. This appliance provides n8n running in a Docker container on Ubuntu 22.04 LTS with VNC access and SSH key authentication.

## Key Features

**n8n capabilities:**
- Workflow automation
- Visual workflow editor
- Self-hosted
- Extensible with custom nodes
- REST API
- Webhook support
**This appliance provides:**
- Ubuntu 22.04 LTS base operating system
- Docker Engine CE pre-installed and configured
- n8n container (n8nio/n8n:latest) ready to run
- VNC access for desktop environment
- SSH key authentication from OpenNebula context
- Configurable container parameters (ports, volumes, environment variables) - Web interface on port 5678

## Quick Start

1. **Deploy the appliance** from OpenNebula marketplace
2. **Configure container settings** during VM instantiation:
- Container name: n8n-container
- Port mappings: 5678:5678
- Environment variables: N8N_HOST=0.0.0.0,N8N_PORT=5678,N8N_PROTOCOL=http,N8N_SECURE_COOKIE=false
- Volume mounts: /data:/home/node/.n8n
3. **Access the VM**:
- VNC: Direct desktop access
- SSH: `ssh root@VM_IP` (using OpenNebula context keys) - Web: n8n interface at http://VM_IP:5678

## Container Configuration

### Port Mappings
Format: `host_port:container_port,host_port2:container_port2`
Default: `5678:5678`

### Environment Variables
Format: `VAR1=value1,VAR2=value2`
Default: `N8N_HOST=0.0.0.0,N8N_PORT=5678,N8N_PROTOCOL=http,N8N_SECURE_COOKIE=false`

### Volume Mounts
Format: `/host/path:/container/path,/host/path2:/container/path2`
Default: `/data:/home/node/.n8n`

## Management Commands

```bash
# View running containers
docker ps

# View container logs
docker logs n8n-container

# Access container shell
docker exec -it n8n-container /bin/bash

# Restart container
docker restart n8n-container

# Stop container
docker stop n8n-container

# Start container
docker start n8n-container
```

## Technical Details

- **Base OS**: Ubuntu 22.04 LTS
- **Container Runtime**: Docker Engine CE
- **Container Image**: n8nio/n8n:latest
- **Default Ports**: 5678:5678
- **Default Volumes**: /data:/home/node/.n8n
- **Memory Requirements**: 2GB minimum
- **Disk Requirements**: 8GB minimum

## Version History

See [CHANGELOG.md](CHANGELOG.md) for detailed version history.
232 changes: 232 additions & 0 deletions appliances/n8n/appliance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
#!/usr/bin/env bash

# n8n Appliance Installation Script
# Auto-generated by OpenNebula Docker Appliance Generator
# Docker Image: n8nio/n8n:latest

set -o errexit -o pipefail

# List of contextualization parameters
ONE_SERVICE_PARAMS=(
'ONEAPP_CONTAINER_NAME' 'configure' 'Docker container name' 'O|text'
'ONEAPP_CONTAINER_PORTS' 'configure' 'Docker container port mappings' 'O|text'
'ONEAPP_CONTAINER_ENV' 'configure' 'Docker container environment variables' 'O|text'
'ONEAPP_CONTAINER_VOLUMES' 'configure' 'Docker container volume mappings' 'O|text'
)

# Configuration from user input
DOCKER_IMAGE="n8nio/n8n:latest"
DEFAULT_CONTAINER_NAME="n8n-container"
DEFAULT_PORTS="5678:5678"
DEFAULT_ENV_VARS="N8N_HOST=0.0.0.0,N8N_PORT=5678,N8N_PROTOCOL=http,N8N_SECURE_COOKIE=false"
DEFAULT_VOLUMES="/data:/home/node/.n8n"
APP_NAME="n8n"
APPLIANCE_NAME="n8n"

### Appliance metadata ###############################################

ONE_SERVICE_NAME='n8n'
ONE_SERVICE_VERSION='1.0' # Appliance version
ONE_SERVICE_BUILD=$(date +%s)
ONE_SERVICE_SHORT_DESCRIPTION='n8n Docker Container Appliance'
ONE_SERVICE_DESCRIPTION='n8n running in Docker container'
ONE_SERVICE_RECONFIGURABLE=true

### Appliance functions ##############################################

service_cleanup()
{
:
}

service_install()
{
export DEBIAN_FRONTEND=noninteractive

# Update system
apt-get update
apt-get upgrade -y

# Install Docker
apt-get install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Enable and start Docker
systemctl enable docker
systemctl start docker

# Pull the Docker image
msg info "Pulling Docker image: $DOCKER_IMAGE"
docker pull "$DOCKER_IMAGE"

# Configure console auto-login
systemctl stop unattended-upgrades 2>/dev/null || true
systemctl disable unattended-upgrades 2>/dev/null || true

apt-get install -y mingetty

# Configure auto-login on console
mkdir -p /etc/systemd/system/[email protected]
cat > /etc/systemd/system/[email protected]/override.conf << 'CONSOLE_EOF'
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin root %I \\$TERM
Type=idle
CONSOLE_EOF

# Configure serial console and set root password
mkdir -p /etc/systemd/system/[email protected]
cat > /etc/systemd/system/[email protected]/override.conf << 'SERIAL_EOF'
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin root %I 115200,38400,9600 vt102
Type=idle
SERIAL_EOF

echo 'root:opennebula' | chpasswd
systemctl enable [email protected] [email protected]

# Create welcome message
cat > /etc/profile.d/99-$APPLIANCE_NAME-welcome.sh << 'WELCOME_EOF'
#!/bin/bash
case \\$- in
*i*) ;;
*) return;;
esac

echo "=================================================="
echo " $APP_NAME Appliance"
echo "=================================================="
echo " Docker Image: $DOCKER_IMAGE"
echo " Container: $DEFAULT_CONTAINER_NAME"
echo " Ports: $DEFAULT_PORTS"
echo ""
echo " Commands:"
echo " docker ps - Show running containers"
echo " docker logs $DEFAULT_CONTAINER_NAME - View container logs"
echo " docker exec -it $DEFAULT_CONTAINER_NAME /bin/bash - Access container"
echo ""
EOF

if [ "$WEB_INTERFACE" = "true" ]; then
cat >> "$REPO_ROOT/appliances/$APPLIANCE_NAME/appliance.sh" << EOF
echo " Web Interface: http://VM_IP:$APP_PORT"
echo ""
EOF
fi

cat >> "$REPO_ROOT/appliances/$APPLIANCE_NAME/appliance.sh" << 'EOF'
echo " Access Methods:"
echo " SSH: Enabled (password: 'opennebula' + context keys)"
echo " Console: Auto-login as root (via OpenNebula console)"
echo " Serial: Auto-login as root (via serial console)"
echo "=================================================="
WELCOME_EOF

chmod +x /etc/profile.d/99-$APPLIANCE_NAME-welcome.sh

# Clean up
apt-get autoremove -y
apt-get autoclean
find /var/log -type f -exec truncate -s 0 {} \;

sync

return 0
}

service_configure()
{
msg info "Verifying Docker is running"

if ! systemctl is-active --quiet docker; then
msg error "Docker is not running"
return 1
fi

msg info "Docker is running"
return 0
}

service_bootstrap()
{
msg info "Starting $APP_NAME service bootstrap"

# Setup and start the container
setup_app_container

return $?
}

# Setup container function
setup_app_container()
{
local container_name="${ONEAPP_CONTAINER_NAME:-$DEFAULT_CONTAINER_NAME}"
local container_ports="${ONEAPP_CONTAINER_PORTS:-$DEFAULT_PORTS}"
local container_env="${ONEAPP_CONTAINER_ENV:-$DEFAULT_ENV_VARS}"
local container_volumes="${ONEAPP_CONTAINER_VOLUMES:-$DEFAULT_VOLUMES}"

msg info "Setting up $APP_NAME container: $container_name"

# Stop and remove existing container if it exists
if docker ps -a --format '{{.Names}}' | grep -q "^${container_name}$"; then
msg info "Stopping existing container: $container_name"
docker stop "$container_name" 2>/dev/null || true
docker rm "$container_name" 2>/dev/null || true
fi

# Parse port mappings
local port_args=""
if [ -n "$container_ports" ]; then
IFS=',' read -ra PORT_ARRAY <<< "$container_ports"
for port in "${PORT_ARRAY[@]}"; do
port_args="$port_args -p $port"
done
fi

# Parse environment variables
local env_args=""
if [ -n "$container_env" ]; then
IFS=',' read -ra ENV_ARRAY <<< "$container_env"
for env in "${ENV_ARRAY[@]}"; do
env_args="$env_args -e $env"
done
fi

# Parse volume mounts
local volume_args=""
if [ -n "$container_volumes" ]; then
IFS=',' read -ra VOL_ARRAY <<< "$container_volumes"
for vol in "${VOL_ARRAY[@]}"; do
local host_path=$(echo "$vol" | cut -d':' -f1)
mkdir -p "$host_path"
# Set ownership to 1000:1000 (common for Docker containers)
chown -R 1000:1000 "$host_path" 2>/dev/null || true
volume_args="$volume_args -v $vol"
done
fi

# Start the container
msg info "Starting $APP_NAME container with:"
msg info " Ports: $container_ports"
msg info " Environment: ${container_env:-none}"
msg info " Volumes: $container_volumes"

docker run -d --name "$container_name" --restart unless-stopped $port_args $env_args $volume_args "$DOCKER_IMAGE"

if [ $? -eq 0 ]; then
msg info "$APP_NAME container started successfully"
docker ps --filter name="$container_name"
return 0
else
msg error "Failed to start $APP_NAME container"
return 1
fi
}
66 changes: 66 additions & 0 deletions appliances/n8n/cf81cb32-dde4-4d47-a09c-fc3b4f058f45.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: n8n
version: 1.0.0-1
one-apps_version: 7.0.0-0
publisher: Pablo de la Rco
publisher_email: [email protected]
description: |-
n8n is a workflow automation tool that allows you to connect different services and automate tasks. This appliance provides n8n
running in a Docker container on Ubuntu 22.04 LTS with VNC access and
SSH key authentication.

**n8n features:**
- Workflow automation
- Visual workflow editor
- Self-hosted
- Extensible with custom nodes
- REST API
- Webhook support
**This appliance provides:**
- Ubuntu 22.04 LTS base operating system
- Docker Engine CE pre-installed and configured
- n8n container (n8nio/n8n:latest) ready to run
- VNC access for desktop environment
- SSH key authentication from OpenNebula context - Web interface on port 5678
- Configurable container parameters (ports, volumes, environment variables)

**Access Methods:**
- VNC: Direct access to desktop environment
- SSH: Key-based authentication from OpenNebula - Web: n8n interface at http://VM_IP:5678

short_description: n8n with VNC access and SSH key auth
tags:
- n8n
- docker
- ubuntu
- container
- vnc
- ssh-key
format: qcow2
creation_time: 1759334415
os-id: Ubuntu
os-release: '22.04'
os-arch: x86_64
hypervisor: KVM
opennebula_version: 7.0
opennebula_template:
context:
network: 'YES'
ssh_public_key: $USER[SSH_PUBLIC_KEY]
set_hostname: $USER[SET_HOSTNAME]
cpu: '2'
disk:
image: $FILE[IMAGE_ID]
image_uname: $USER[IMAGE_UNAME]
graphics:
listen: 0.0.0.0
type: vnc
memory: '2048'
name: n8n
user_inputs:
oneapp_container_name: 'M|text|Container name|n8n-container|n8n-container'
oneapp_container_ports: 'M|text|Container ports (format: host:container)|5678:5678|5678:5678'
oneapp_container_env: 'O|text|Environment variables (format: VAR1=value1,VAR2=value2)|N8N_HOST=0.0.0.0,N8N_PORT=5678,N8N_PROTOCOL=http|'
oneapp_container_volumes: 'O|text|Volume mounts (format: /host/path:/container/path)|/data:/home/node/.n8n|'
inputs_order: ONEAPP_CONTAINER_NAME,ONEAPP_CONTAINER_PORTS,ONEAPP_CONTAINER_ENV,ONEAPP_CONTAINER_VOLUMES
logo: logos/n8n.png
Loading