> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nextoriahub.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Self-Hosted Deployment

> Run Nextoria Hub on your own infrastructure using Docker or Kubernetes.

<Warning>
  Self-hosted deployment is available on the **Scale plan** only. A valid
  Scale-tier license key is required to run the self-hosted build.
</Warning>

## Requirements

| Component      | Minimum          | Recommended      |
| -------------- | ---------------- | ---------------- |
| CPU            | 2 vCPU           | 4 vCPU           |
| RAM            | 4 GB             | 8 GB             |
| Storage        | 50 GB SSD        | 200 GB SSD       |
| OS             | Ubuntu 22.04 LTS | Ubuntu 22.04 LTS |
| Docker         | 24.x             | 24.x             |
| Docker Compose | 2.x              | 2.x              |

## Quick Start with Docker Compose

```bash theme={null}
# Download the Nextoria Hub self-hosted bundle
curl -fsSL https://nextoriahub.com/install.sh | bash

# Navigate to the directory
cd nextoriahub

# Copy and configure the environment file
cp .env.example .env
nano .env

# Start all services
docker compose up -d
```

The application will be available at `http://your-server-ip:3000`.

## Environment Configuration

Edit the `.env` file with your configuration:

```env theme={null}
# Application
APP_URL=https://app.youragency.com
LICENSE_KEY=YOUR_SCALE_LICENSE_KEY

# Database (PostgreSQL)
DATABASE_URL=postgresql://user:password@db:5432/nextoriahub

# Authentication
JWT_SECRET=your-256-bit-secret
SESSION_SECRET=another-256-bit-secret

# Stripe
STRIPE_SECRET_KEY=sk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...

# Stream Chat
STREAM_API_KEY=...
STREAM_API_SECRET=...

# File Storage (S3-compatible)
S3_BUCKET=nextoriahub-files
S3_REGION=us-east-1
S3_ACCESS_KEY_ID=...
S3_SECRET_ACCESS_KEY=...

# Email (SMTP)
SMTP_HOST=smtp.yourmailprovider.com
SMTP_PORT=587
SMTP_USER=notifications@youragency.com
SMTP_PASSWORD=...
EMAIL_FROM=Nextoria Hub <no-reply@youragency.com>
```

## Docker Compose Services

The self-hosted bundle runs the following services:

| Service | Description                                      | Port    |
| ------- | ------------------------------------------------ | ------- |
| `app`   | Nextoria Hub web application                     | 3000    |
| `api`   | Backend API server                               | 4000    |
| `db`    | PostgreSQL 16 database                           | 5432    |
| `redis` | Redis for sessions and queues                    | 6379    |
| `minio` | S3-compatible file storage (if not using AWS S3) | 9000    |
| `nginx` | Reverse proxy + SSL termination                  | 80, 443 |

## SSL Configuration

The included `nginx` service handles SSL termination via Let's Encrypt (Certbot):

```bash theme={null}
# Issue SSL certificate for your domain
docker compose run --rm certbot certonly --webroot \
  --webroot-path=/var/www/certbot \
  -d app.youragency.com

# Restart nginx to load the certificate
docker compose restart nginx
```

## Updates

Pull and apply updates:

```bash theme={null}
docker compose pull
docker compose up -d
docker compose exec api bun db:migrate
```

We recommend subscribing to [nextoriahub.com/changelog](https://nextoriahub.com/changelog) for release notifications.

## Backups

Automate database backups with a cron job:

```bash theme={null}
# Add to crontab: crontab -e
0 2 * * * docker compose exec -T db pg_dump -U postgres nextoriahub | gzip > /backups/nextoriahub-$(date +%Y%m%d).sql.gz
```

Retain at least 30 days of daily backups and store them off-server (S3, Backblaze, etc.).

## Kubernetes

Helm charts for Kubernetes deployment are available for Scale customers. Contact your dedicated Success Manager for the Helm chart package and deployment guidance.
