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

# Docker

> Single docker image deployment with SQLite3 and Memory Queue

<Warning>
  This setup is only meant for personal use or testing. It runs on SQLite3 and an in-memory Redis queue, which supports only a single instance on a single machine. For production or multi-instance setups, you must use Docker Compose with PostgreSQL and Redis.
</Warning>

To get up and running quickly with NRAI, we will use the NRAI Docker image. Follow these steps:

## Prerequisites

You need to have [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Docker](https://docs.docker.com/get-docker/) installed on your machine in order to set up NRAI via Docker Compose.

## Install

### Pull Image and Run Docker image

Pull the NRAI Docker image and run the container with the following command:

```bash theme={null}
docker run -d -p 8080:80 -v ~/.NRAI:/root/.NRAI -e AP_REDIS_TYPE=MEMORY -e AP_DB_TYPE=SQLITE3 -e AP_FRONTEND_URL="http://localhost:8080" NRAI/NRAI:latest
```

### Configure Webhook URL (Important for Triggers, Optional If you have public IP)

**Note:** By default, NRAI will try to use your public IP for webhooks. If you are self-hosting on a personal machine, you must configure the frontend URL so that the webhook is accessible from the internet.

**Optional:** The easiest way to expose your webhook URL on localhost is by using a service like ngrok. However, it is not suitable for production use.

1. Install ngrok
2. Run the following command:

```bash theme={null}
ngrok http 8080
```

3. Replace `AP_FRONTEND_URL` environment variable in the command line above.

<img src="https://mintlify.s3.us-west-1.amazonaws.com/newratantechnologiespvtltd/resources/screenshots/docker-ngrok.png" alt="Ngrok" />

## Upgrade

Please follow the steps below:

### Step 1: Back Up Your Data (Recommended)

Before proceeding with the upgrade, it is always a good practice to back up your NRAI data to avoid any potential data loss during the update process.

1. **Stop the Current NRAI Container:** If your NRAI container is running, stop it using the following command:
   ```bash theme={null}
   docker stop nrai_container_name
   ```

2. **Backup NRAI Data Directory:** By default, NRAI data is stored in the `~/.NRAI` directory on your host machine. Create a backup of this directory to a safe location using the following command:
   ```bash theme={null}
   cp -r ~/.NRAI ~/.NRAI_backup
   ```

### Step 2: Update the Docker Image

1. **Pull the Latest NRAI Docker Image:** Run the following command to pull the latest NRAI Docker image from Docker Hub:
   ```bash theme={null}
   docker pull NRAI/NRAI:latest
   ```

### Step 3: Remove the Existing NRAI Container

1. **Stop and Remove the Current NRAI Container:** If your NRAI container is running, stop and remove it using the following commands:
   ```bash theme={null}
   docker stop nrai_container_name
   docker rm nrai_container_name
   ```

### Step 4: Run the Updated NRAI Container

Now, run the updated NRAI container with the latest image using the same command you used during the initial setup. Be sure to replace `nrai_container_name` with the desired name for your new container.

```bash theme={null}
docker run -d -p 8080:80 -v ~/.NRAI:/root/.NRAI -e AP_REDIS_TYPE=MEMORY -e AP_DB_TYPE=SQLITE3 -e AP_FRONTEND_URL="http://localhost:8080" --name nrai_container_name NRAI/NRAI:latest
```

Congratulations! You have successfully upgraded your NRAI Docker deployment
