# Installation — Cloudflare

> Deploy ARI.Software to Cloudflare Containers with one click using the Deploy to Cloudflare button.

Deploy ARI to Cloudflare with one click. No terminal required.

You can install ARI on your own macOS, Windows or Linux computer, or host it in the cloud. On Cloudflare, ARI runs in a [Cloudflare Container](https://developers.cloudflare.com/containers/). Cloudflare builds ARI from your own copy of the code, runs it on its global network, and rebuilds it whenever that code changes. ARI starts when someone visits and goes to sleep after 30 minutes without visits.

## What You Need

- **A Cloudflare account on the Workers Paid plan** ($5 per month). Containers are not available on the free plan. Container use beyond what the plan includes is billed separately; see [Cloudflare's container pricing](https://developers.cloudflare.com/containers/pricing/).
- **A GitHub account.** Cloudflare creates your copy of ARI there.
- **A PostgreSQL database.** A free Supabase or Neon database works. See [Step 3](https://ari.software/docs/installation-cloudflare#database).

## Step 1 — Create a Cloudflare Account

Create an account at [dash.cloudflare.com](https://dash.cloudflare.com/sign-up), or sign in if you already have one. Then upgrade to Workers Paid: in the dashboard, open **Workers & Pages**, go to **Plans** and choose **Workers Paid**.

## Step 2 — Deploy

Once you are signed in to Cloudflare, click the deploy button below:

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/ARIsoftware/ARI)

Cloudflare opens a **Create an app** screen. Fill it in as follows:

1. **Git account.** Connect GitHub if Cloudflare asks. Then choose the GitHub account or organization where your copy of ARI should live. Cloudflare creates a new repository there and redeploys ARI every time it changes. Tick **Create private Git repository** to keep it private.
2. **Project name.** This becomes the name of your Worker (the small Cloudflare program that runs ARI's container) and part of ARI's address: `https://*project-name*.*your-subdomain*.workers.dev`. Cloudflare also gives the new repository this name, so pick one the Git account doesn't already use, such as `my-ari`.
3. **ARI\_DEPLOYMENT\_TARGET.** Leave it as `cloudflare`.
4. **ARI\_CONTAINER\_INSTANCE.** The size of ARI's container. The default, `basic`, has ¼ of a CPU and 1 GiB of memory. If ARI feels slow, choose a larger size: `standard-1` to `standard-4` add CPU and memory, at a higher cost.
5. **Build command** and **Deploy command.** Leave them as `pnpm run build` and `npx wrangler deploy`.
6. **Enable Preview builds.** Turn this **off**. ARI doesn't use preview builds, and each one would rebuild ARI's whole container image whenever another branch changes.
7. **Protect with Cloudflare Access.** Leave it off.
8. Click **Deploy**.

The first build takes several minutes, because Cloudflare builds ARI's container image from scratch. When it finishes, open ARI's address, which the Worker's page in the dashboard shows: `https://*project-name*.*your-subdomain*.workers.dev`. The first visit starts ARI. An **ARI is starting** page refreshes itself every 15 seconds until ARI is ready, and then the setup wizard opens.

Complete setup at this `workers.dev` address, not on a custom domain. ARI uses the address to check that your Cloudflare API token belongs to the account that runs it. You can add a custom domain afterwards. See [After Setup](https://ari.software/docs/installation-cloudflare#after-setup).

The wizard first asks you to create your admin account and enter your personal details. Its last step, **Deploy**, needs a database, a Cloudflare API token and, optionally, a GitHub token. Steps 3 to 5 explain how to get them.

## Step 3 — Set Up a Database

ARI needs a PostgreSQL database. Cloudflare's own database, D1, is not supported, because it is SQLite rather than PostgreSQL. Create a free hosted database with either provider below and copy its connection string into the wizard.

**Supabase**

Create a project at [supabase.com](https://supabase.com). Then open **Connect** (top of the dashboard) and choose the connection string carefully:

  - Choose the **Session pooler**. Don't use the **Transaction pooler** (port 6543): it can't hold the lock ARI takes while it creates your admin account. Don't use the **Direct connection** either: it is IPv6-only unless you buy Supabase's IPv4 add-on.
  - Set **Type** to **URI** and copy the string. It looks like `postgresql://postgres.*your-project-ref*:[YOUR-PASSWORD]@aws-0-*region*.pooler.supabase.com:5432/postgres`. Look for port **5432** and the `postgres.<ref>` username.
  - Replace `[YOUR-PASSWORD]` with your database password. If the password contains special characters, [percent-encode](https://en.wikipedia.org/wiki/Percent-encoding) them.

**Neon**

Create a project at [neon.tech](https://neon.tech), open **Connect** and turn off **Connection pooling** to get the direct connection string, whose host doesn't contain `-pooler`. Neon's pooled string has the same limitation as Supabase's Transaction pooler.

ARI tests the connection before it saves anything, so a wrong string fails right away with a clear message instead of breaking your deployment.

## Step 4 — Create a Cloudflare API Token

ARI uses this token once, to find your Worker and save your configuration on it as encrypted secrets. ARI never stores, logs or shows the token again.

1. Open [dash.cloudflare.com/profile/api-tokens](https://dash.cloudflare.com/profile/api-tokens) (**My Profile → API Tokens**). Create the token there, on your profile. Account API tokens, under **Manage Account**, don't work: ARI rejects them.
2. Click **Create Token** and give it a name, such as `ARI setup`.
3. Under **Policies**, choose **Start from scratch**, then **Start with an Account policy**.
4. Add these three permissions:

| Permission | Access | What ARI uses it for |
| --- | --- | --- |
| Workers Scripts | Edit | Saves your configuration as secrets on your Worker. |
| Account Settings | Read | Confirms that the token belongs to the account that runs this Worker, by matching your `workers.dev` subdomain. |
| Workers Builds Configuration | Read | Finds the GitHub repository and branch that Cloudflare deploys from, so module installs know where to commit. |

5. Choose the account that runs ARI rather than **All accounts**, so the token can't change Workers in your other Cloudflare accounts.
6. Set an expiration. **7 days** is plenty.
7. Review the summary and click **Create Token**. Copy the token now, because Cloudflare shows it only once. Paste it into the **API Token** field in the wizard.

If the wizard also asks for an **Account ID**, copy it from the **Workers & Pages** overview in the Cloudflare dashboard, or from the dashboard's address bar.

## Step 5 — Create a GitHub Token (Optional)

The **GitHub Token** field lets you install new modules from the Modules page. Cloudflare wipes the container's disk whenever ARI restarts, so ARI installs a module by committing it to your repository. Cloudflare then rebuilds ARI with the module included.

1. Open [github.com/settings/personal-access-tokens](https://github.com/settings/personal-access-tokens/new) to create a fine-grained token.
2. **Resource owner:** the account or organization that owns your ARI repository, which is the Git account you chose in Step 2.
3. **Expiration:** your choice. ARI keeps using this token for module installs, so when it expires you'll need to replace it.
4. **Repository access:** choose **Only select repositories** and pick your ARI repository.
5. **Permissions:** under **Repository permissions**, set **Contents** to **Read and write**. GitHub adds **Metadata: Read-only** automatically.
6. Click **Generate token**, copy it and paste it into the **GitHub Token** field in the wizard.

If the repository belongs to an organization that requires approval for fine-grained tokens, an organization owner must approve the token before it works. ARI finds your repository and branch automatically. If it can't, the wizard asks for them.

## Step 6 — Configure & Restart

In the wizard's **Deploy** step, paste your database connection string and keep the auto-generated authentication secret. Then paste your Cloudflare API token and, optionally, your GitHub token, and click **Configure & Restart**. ARI will:

1. Check that the Cloudflare token belongs to the account that runs this Worker.
2. Test the database connection. If it fails, nothing is saved.
3. Save your configuration as encrypted secrets on your Worker.
4. Restart with the new settings. This usually takes 1–5 minutes. Keep the tab open; the **ARI is starting** page may appear while it restarts.

When it's done, click **Sign in to ARI** and sign in with the admin email and password you chose. ARI creates your account and database tables automatically the first time you sign in.

## After Setup

- **Delete the Cloudflare API token.** ARI no longer needs it. Remove it under **My Profile → API Tokens**.
- **Changing settings.** All of ARI's configuration is under **Workers & Pages → your Worker → Settings → Variables and Secrets**. When you add or change a value there, ARI restarts with it within a few minutes. Never change `BETTER_AUTH_SECRET`: ARI uses it to encrypt the API keys you store, and changing it makes them unreadable.
- **First-run credentials.** `ARI_FIRST_RUN_ADMIN_EMAIL` and `ARI_FIRST_RUN_ADMIN_PASSWORD` are one-time secrets that ARI ignores once your account exists. You can safely delete them under **Variables and Secrets**.
- **File storage.** The container's disk is wiped whenever ARI restarts, so uploaded files need permanent storage. Create a [Cloudflare R2](https://developers.cloudflare.com/r2/) bucket and an R2 API token. Then add these secrets: `ARI_STORAGE_PROVIDER` (set to `r2`), `ARI_R2_ACCOUNT_ID`, `ARI_R2_ACCESS_KEY_ID`, `ARI_R2_SECRET_ACCESS_KEY` and `ARI_R2_BUCKET`. See [Storage](https://ari.software/docs/storage).
- **Installing modules.** With a GitHub token, each module install commits to your repository. Cloudflare rebuilds ARI, which takes several minutes, and ARI restarts with the new module. If you skipped the GitHub token in the wizard, add these secrets: `GITHUB_TOKEN` (see [Step 5](https://ari.software/docs/installation-cloudflare#github-token)), `GITHUB_REPO_OWNER`, `GITHUB_REPO_NAME` and `GITHUB_BRANCH` (the branch Cloudflare deploys from, usually `main`).
- **Sleeping.** After 30 minutes without visits, ARI's container stops. The next visit starts it again, and the **ARI is starting** page appears for a moment.
- **Custom domain.** Add your domain under **Settings → Domains & Routes** on your Worker. Then set the `BETTER_AUTH_URL` and `NEXT_PUBLIC_APP_URL` secrets to `https://*your-domain*`. After ARI restarts, sign in at your domain; ARI accepts sign-ins only at the address in those two secrets.

## Troubleshooting

| Problem | What to do |
| --- | --- |
| The build fails with an `Unauthorized` error from the containers API | Containers need the Workers Paid plan. Upgrade ([Step 1](https://ari.software/docs/installation-cloudflare#step-1)), then run the build again from your Worker's page. |
| `Cloudflare could not create the Git repository right now` | A repository with that name probably already exists in the chosen Git account (GitHub ignores upper and lower case), or Cloudflare isn't allowed to create repositories there. Choose a different project name or Git account. |
| The **ARI is starting** page keeps coming back | Check that your account is on Workers Paid, then open your Worker's **Logs** in the dashboard to see why the container doesn't start. |
| `Finish setup at this Worker's workers.dev address` | You opened the wizard on another domain. Open `https://*project-name*.*your-subdomain*.workers.dev` and complete setup there. |
| `This is an account API token` | Create the token under **My Profile → API Tokens** instead. See [Step 4](https://ari.software/docs/installation-cloudflare#cloudflare-token). |
| `Cloudflare rejected the API token` | The token has expired or is missing a permission. Create a new one with the three permissions in Step 4. |
| `ARI couldn't find the Cloudflare account that runs this Worker` | Enter your Account ID in the field that appears, and check that the token was created for that account. |
| `Database connection failed — nothing was saved` | Check the connection string and password. On Supabase, use the Session pooler string (port 5432). See [Step 3](https://ari.software/docs/installation-cloudflare#database). |
| `ARI couldn't detect the GitHub repository this Worker deploys from` | Enter the repository owner, name and branch in the fields that appear. |
| **Still restarting…** | Your configuration was saved, so there's nothing to enter again. Check your Worker's logs in the dashboard, then reload the page. |

## Managed Setup

Prefer not to deal with infrastructure? The Managed Setup plan includes full hosting on your own custom domain, daily backups, and professional setup. Contact [hello@ari.software](mailto:hello@ari.software) for details.

## Your Personal Workspace. Your Rules.

Source Code Available. Self-Hosted. Full Data Control. Fully Extendable. AI Native. Dozens of Built-In Modules And Build Your Own In Minutes. No Coding Required.

[Get Started](https://ari.software/docs/installation)

---

Source: https://ari.software/docs/installation-cloudflare

Markdown rendering of this page, served for `Accept: text/markdown`. Full site index for agents: https://ari.software/llms.txt

