|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: 2025 Amritpal Singh <[email protected]> |
| 3 | +
|
| 4 | +SPDX-License-Identifier: AGPL-3.0-or-later |
| 5 | +--> |
| 6 | + |
| 7 | +# Lens App Installation Guide for TrueNAS SCALE |
| 8 | + |
| 9 | +This guide provides step-by-step instructions for installing Lens on TrueNAS SCALE using Custom App Install via YAML. |
| 10 | + |
| 11 | +## Table of Contents |
| 12 | + |
| 13 | +- [Overview](#overview) |
| 14 | +- [Prerequisites](#prerequisites) |
| 15 | +- [Storage Setup](#storage-setup) |
| 16 | +- [Installation Steps](#installation-steps) |
| 17 | +- [Configuration](#configuration) |
| 18 | +- [Accessing Services](#accessing-services) |
| 19 | + |
| 20 | +## Overview |
| 21 | + |
| 22 | +The Lens App deploys a complete Lens stack on TrueNAS SCALE, including: |
| 23 | + |
| 24 | +- **Backend API** - Main application server (port 30305) |
| 25 | +- **Frontend** - Web interface (port 30306) |
| 26 | +- **MongoDB** - Database (port 27018) |
| 27 | +- **Redis** - Cache and message broker for workers |
| 28 | +- **FC Worker API** - FreeCAD worker API |
| 29 | +- **FC Worker Celery** - Background task processor |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +Before installing, ensure you have: |
| 34 | + |
| 35 | +1. **TrueNAS SCALE** with Apps enabled |
| 36 | +2. **Storage pool** available for persistent data |
| 37 | +3. **Network access** to the TrueNAS host |
| 38 | + |
| 39 | +## Storage Setup |
| 40 | + |
| 41 | +### Step 1: Determine Your Storage Path |
| 42 | + |
| 43 | +You need to identify where to store persistent data. Common options: |
| 44 | + |
| 45 | +- **Apps pool** (recommended): `/mnt/[pool-name]/ix-applications/lens/...` |
| 46 | + - Find your Apps pool in: **Apps > Settings > Advanced Settings > Pool** |
| 47 | +- **Custom dataset**: `/mnt/[pool-name]/[dataset-name]/lens/...` |
| 48 | + |
| 49 | +### Step 2: Create Required Directories |
| 50 | + |
| 51 | +Open the TrueNAS Shell (System Settings > Shell) or SSH into your TrueNAS host: |
| 52 | + |
| 53 | +```bash |
| 54 | +# Replace /mnt/[your-pool] with your actual Apps pool path |
| 55 | +# Example: /mnt/tank/ix-applications/lens |
| 56 | + |
| 57 | +# Create MongoDB data directory |
| 58 | +mkdir -p /mnt/[your-pool]/ix-applications/lens/mongodb_data |
| 59 | + |
| 60 | +# Create uploads directory |
| 61 | +mkdir -p /mnt/[your-pool]/ix-applications/lens/uploads_data |
| 62 | + |
| 63 | +# Set MongoDB directory ownership (MongoDB runs as user 568:568) |
| 64 | +chown -R 568:568 /mnt/[your-pool]/ix-applications/lens/mongodb_data |
| 65 | +``` |
| 66 | + |
| 67 | +### Step 3: Verify Directory Permissions |
| 68 | + |
| 69 | +```bash |
| 70 | +# Check MongoDB directory |
| 71 | +ls -la /mnt/[your-pool]/ix-applications/lens/mongodb_data |
| 72 | + |
| 73 | +# Check uploads directory |
| 74 | +ls -la /mnt/[your-pool]/ix-applications/lens/uploads_data |
| 75 | +``` |
| 76 | + |
| 77 | +## Installation Steps |
| 78 | + |
| 79 | +### Step 1: Open Custom App YAML Editor |
| 80 | + |
| 81 | +1. Log in to your TrueNAS SCALE web interface |
| 82 | +2. Navigate to **Apps > Discover Apps** |
| 83 | +3. Click the **three-dot menu (⋮)** next to **Custom App** |
| 84 | +4. Select **Install via YAML** from the menu |
| 85 | +5. A YAML editor will open |
| 86 | + |
| 87 | +### Step 2: Paste Configuration |
| 88 | + |
| 89 | +1. Copy the contents of `lens-truenas-app.yaml` |
| 90 | +2. Paste it into the YAML editor |
| 91 | +3. **Important**: Before proceeding, you must update the configuration (see [Configuration](#configuration) below) |
| 92 | + |
| 93 | +### Step 3: Update Configuration |
| 94 | + |
| 95 | +Before deploying, update the following in the YAML: |
| 96 | + |
| 97 | +#### Storage Paths |
| 98 | + |
| 99 | +Replace all instances of `/mnt/[your-pool]/ix-applications/lens` with your actual storage path: |
| 100 | + |
| 101 | +```yaml |
| 102 | +volumes: |
| 103 | + - /mnt/[your-pool]/ix-applications/lens/mongodb_data:/data/db |
| 104 | + - /mnt/[your-pool]/ix-applications/lens/uploads_data:/app/uploads |
| 105 | +``` |
| 106 | +
|
| 107 | +#### Network Configuration |
| 108 | +
|
| 109 | +Update the `HOSTNAME`, `FRONTEND_URL`, and `VITE_APP_API_URL` environment variables: |
| 110 | + |
| 111 | +```yaml |
| 112 | +environment: |
| 113 | + - HOSTNAME=192.168.1.100 # Replace with your TrueNAS IP or hostname |
| 114 | + - FRONTEND_URL=http://192.168.1.100:30306 # Update accordingly |
| 115 | + - VITE_APP_API_URL=http://192.168.1.100:30305/ # Backend API URL (used by both frontend and backend) |
| 116 | +``` |
| 117 | + |
| 118 | +#### Admin Credentials |
| 119 | + |
| 120 | +**⚠️ SECURITY WARNING**: Change the default admin credentials before deploying: |
| 121 | + |
| 122 | +```yaml |
| 123 | +environment: |
| 124 | + |
| 125 | + - DEFAULT_ADMIN_USERNAME=admin # Change this |
| 126 | + |
| 127 | + - DEFAULT_ADMIN_NAME=Administrator |
| 128 | +``` |
| 129 | + |
| 130 | +#### SMTP Configuration (Optional) |
| 131 | + |
| 132 | +If you want email functionality, configure SMTP: |
| 133 | + |
| 134 | +```yaml |
| 135 | +environment: |
| 136 | + - SMTP_HOST=smtp.example.com |
| 137 | + - SMTP_PORT=465 |
| 138 | + |
| 139 | + - SMTP_PASS=your-password |
| 140 | + |
| 141 | +``` |
| 142 | + |
| 143 | +#### Port Configuration |
| 144 | + |
| 145 | +Adjust ports if they conflict with other services: |
| 146 | + |
| 147 | +- Backend: `30305:30305` (change this port if needed) |
| 148 | +- Frontend: `30306:80` (change first number if needed) |
| 149 | +- MongoDB: `27018:27017` (change first number if needed) |
| 150 | + |
| 151 | +### Step 4: Deploy |
| 152 | + |
| 153 | +1. Review all configuration changes |
| 154 | +2. Click **Save** to deploy the application |
| 155 | +3. TrueNAS will start pulling images and creating containers |
| 156 | + |
| 157 | +### Step 5: Monitor Deployment |
| 158 | + |
| 159 | +1. Navigate to **Apps** |
| 160 | +2. You will see all running instances listed |
| 161 | +3. Check the status of your Lens app |
| 162 | +4. Select the Lens app to view the status of all Lens services: |
| 163 | + - Wait for all services to show "Running" status |
| 164 | + - Check logs if any service fails to start |
| 165 | + |
| 166 | +## Configuration |
| 167 | + |
| 168 | +### Environment Variables Reference |
| 169 | + |
| 170 | +#### Backend Service |
| 171 | + |
| 172 | +| Variable | Description | Required | Default | |
| 173 | +|----------|-------------|----------|---------| |
| 174 | +| `HOSTNAME` | Server hostname or IP | Yes | - | |
| 175 | +| `PORT` | Backend API port | No | 30305 | |
| 176 | +| `FRONTEND_URL` | Frontend application URL | Yes | - | |
| 177 | +| `VITE_APP_API_URL` | Backend API URL (used by both frontend and backend) | Yes | - | |
| 178 | +| `SMTP_HOST` | SMTP server hostname | No | - | |
| 179 | +| `SMTP_PORT` | SMTP server port | No | 465 | |
| 180 | +| `SMTP_USER` | SMTP username | No | - | |
| 181 | +| `SMTP_PASS` | SMTP password | No | - | |
| 182 | +| `SMTP_FROM` | SMTP from address | No | - | |
| 183 | +| `DEFAULT_ADMIN_EMAIL` | Initial admin email | Yes | - | |
| 184 | +| `DEFAULT_ADMIN_USERNAME` | Initial admin username | Yes | - | |
| 185 | +| `DEFAULT_ADMIN_PASSWORD` | Initial admin password | Yes | - | |
| 186 | +| `DEFAULT_ADMIN_NAME` | Initial admin display name | Yes | - | |
| 187 | + |
| 188 | +#### Frontend Service |
| 189 | + |
| 190 | +| Variable | Description | Required | Default | |
| 191 | +|----------|-------------|----------|---------| |
| 192 | +| `VITE_APP_API_URL` | Backend API URL | Yes | - | |
| 193 | +| `VITE_STRIPE_PURCHASE_PEER_URL` | Stripe purchase URL | No | - | |
| 194 | +| `PROXY_SCHEME_PREFIX` | Proxy scheme prefix | No | `http://` | |
| 195 | + |
| 196 | +### Volume Mounts |
| 197 | + |
| 198 | +| Service | Host Path | Container Path | Purpose | |
| 199 | +|---------|-----------|----------------|---------| |
| 200 | +| MongoDB | `/mnt/[pool]/.../mongodb_data` | `/data/db` | Database files | |
| 201 | +| Backend | `/mnt/[pool]/.../uploads_data` | `/app/uploads` | User uploads | |
| 202 | +| Init Container | `/mnt/[pool]/.../uploads_data` | `/mnt/uploads` | Initial file copy | |
| 203 | + |
| 204 | +## Accessing Services |
| 205 | + |
| 206 | +- **Frontend**: `http://[HOSTNAME]:30306` |
| 207 | +- **Backend API**: `http://[HOSTNAME]:30305` |
| 208 | +- **MongoDB** (external): `mongodb://[HOSTNAME]:27018` |
0 commit comments