# PRISM Installation

> Install Trident PRISM via Docker, OS packages, or binary download with systemd service setup.

## Requirements

- **Chromium or Google Chrome** -- PRISM uses headless Chrome for rendering
- **Linux** (x64 or arm64), macOS, or Docker
- **Memory**: minimum 1GB, recommended 2GB+ (Chrome is memory-hungry)
- **Open files**: 65535 recommended (`LimitNOFILE` in systemd)

## Docker Compose (Recommended)

The easiest way to run PRISM. Includes Chromium in the container.

```yaml
# docker-compose.yml
services:
  prism:
    image: ghcr.io/trident-cache/prism:latest
    ports:
      - "4000:4000"   # Proxy
      - "4001:4001"   # Admin API
    environment:
      - PRISM_ORIGIN=http://your-spa:3000
    deploy:
      resources:
        limits:
          memory: 2G
```

```bash
docker compose up -d

# Verify
curl -I http://localhost:4000/
```

### Update Docker to Latest

```bash
docker compose pull
docker compose up -d
```

## OS Packages (Debian/Ubuntu)

```bash
# Add repository
curl -sSfL https://get.trident-cache.com/prism | sh -s -- --add-repo

# Install
apt update
apt install trident-prism

# Install Chromium
apt install chromium

# Start
systemctl enable --now prism
```

## OS Packages (RHEL/Rocky/Fedora)

```bash
# Add repository
curl -sSfL https://get.trident-cache.com/prism | sh -s -- --add-repo

# Install
dnf install trident-prism chromium

# Start
systemctl enable --now prism
```

## Binary Download

```bash
# Download and install (auto-detects OS and architecture)
curl -sSfL https://get.trident-cache.com/prism | sh

# With systemd service setup
curl -sSfL https://get.trident-cache.com/prism | sh -s -- --with-service
```

The installer:

1. Downloads the correct binary for your platform
2. Installs to `/usr/local/bin/prism`
3. With `--with-service`: creates `prism` system user, installs systemd units, creates config directory

## Verify Installation

```bash
# Check version
prism version

# Validate config
prism --config /etc/prism/config.toml validate

# Start manually (foreground)
prism --config /etc/prism/config.toml run
```

## File Locations

| Path | Purpose |
|------|---------|
| `/usr/bin/prism` | Binary |
| `/etc/prism/config.toml` | Configuration |
| `/etc/default/prism` | Environment variables |
| `/var/lib/prism/` | Data directory |
| `/var/log/prism/` | Log directory |
| `/usr/lib/systemd/system/prism.service` | Systemd service |
| `/usr/lib/systemd/system/prism.socket` | Systemd socket |

## Systemd Service

The systemd unit includes security hardening:

```ini
[Service]
Type=simple
User=prism
Group=prism
ExecStart=/usr/bin/prism --config ${PRISM_CONFIG}
Restart=on-failure
RestartSec=5s

# Security
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
MemoryMax=2G
LimitNOFILE=65535
LimitNPROC=4096
```

<Admonition type="warning" title="Chrome needs /dev/shm">
Chrome requires `/dev/shm` for shared memory. The systemd unit includes `ReadWritePaths=/dev/shm`. In Docker, ensure `--shm-size=512m` or mount `/dev/shm`.
</Admonition>

## Environment Variables

Set in `/etc/default/prism`:

```bash
PRISM_CONFIG=/etc/prism/config.toml
# RUST_LOG=info
# CHROME_PATH=/usr/bin/chromium
```

## Next Steps

- [Configuration Reference](https://docs.qoliber.com/docs/trident/prism/configuration) -- all config options explained
- [Admin API](https://docs.qoliber.com/docs/trident/prism/admin-api) -- health checks, metrics, cache purge
