# Server requirements

What Mimeo needs on any host: runtime, the SQLite database and storage, processes, recurring jobs, secrets, environment variables and backups.

This page is written for AI agents. People follow [Deploy Mimeo to your server](https://mimeohq.com/docs/usage/deploy); see [How Mimeo works](https://mimeohq.com/docs/how-it-fits).

Mimeo is a single-tenant Rails app with one SQLite database. It runs on one server with three processes, a persistent `storage/` directory, HTTPS and one stable secret. This page lists each requirement, the environment variables, backups and a checklist for hosts other than Hatchbox.

## Runtime and build

| Item | Requirement |
|---|---|
| Versions | Rails 8.0, Ruby 3.3.6, Node 22.12.0, from the app's `Gemfile`, `.ruby-version` and `.nvmrc` |
| Dependencies | `bundle install`, then `npm install` including dev dependencies (Vite builds the assets) |
| Assets | `RAILS_ENV=production bin/rails assets:precompile` builds the client assets (`public/vite/`) and the server-rendering bundle (`public/vite-ssr/ssr.js`); no separate SSR build step |
| Database | `bin/rails db:prepare` (or `db:migrate`) once per deploy, after `storage/` is mounted; it creates `storage/production.sqlite3` on the first run |
| Seeds | Production seeds create no demo data and no owner account; the first visitor to **Sign up** becomes the owner and signup then closes |

## Database and storage

One SQLite file holds everything: application records, Solid Queue, Solid Cache and Solid Cable. There is no PostgreSQL, MySQL, Redis or separate queue database.

| Path | Holds |
|---|---|
| `storage/production.sqlite3` | The whole database (`config/database.yml`, production) |
| `storage/imports/` | Uploaded CSV files for imports |
| `storage/uploads/` | Email media when **Settings → General → Storage & media** is set to built-in storage |

- `storage/` must be persistent, writable and shared by every release. An ephemeral or release-local `storage/` loses the database on the next deploy.
- Every process that touches the database runs on the same server and the same disk. Don't scale out with replicas that each get their own file.
- Don't set `DATABASE_URL`: Rails would use it in place of the SQLite file. Don't add `QUEUE_DATABASE_URL`, `CACHE_DATABASE_URL` or `CABLE_DATABASE_URL` either.

## Processes

| Process | Command | Notes |
|---|---|---|
| web | `bin/rails server` | Puma on `PORT` (default 3000), behind the HTTPS proxy |
| jobs | `bin/jobs` | Solid Queue supervisor: dispatcher, workers and the recurring scheduler. Nothing sends without it |
| ssr | `bin/vite ssr` | Node server-side renderer on port 13714 of the same server. Keep the port private |

Solid Queue runs as its own `bin/jobs` process by default. Setting `SOLID_QUEUE_IN_PUMA` runs the supervisor inside Puma instead; then remove `bin/jobs`. Never run both: every queue process would run twice against the one database.

Queue workers: one for the `sending` queue (2 threads), and one for `automation` then every other queue (3 threads, `JOB_CONCURRENCY` processes, default 1).

If the `ssr` process is down, pages fall back to client-only rendering: the app still works, but page source shows an empty `<div id="app">`.

## Recurring jobs

The Solid Queue scheduler in `bin/jobs` runs these from `config/recurring.yml`. Don't add OS cron entries for them. Long-term scheduling lives in database rows, so a missed tick delays work and loses nothing.

| Job | Schedule | Does |
|---|---|---|
| `process_due_emails` | Every minute | Sends scheduled emails that are due |
| `flow_tick` | Every minute | Advances flow runs that are due |
| `nightly_engagement_rescore` | 2am daily | Rescores engagement |
| `nightly_suppression_sync` | 3am daily | Syncs suppressions from the sending provider |
| `nightly_segment_snapshot` | 4am daily | Records segment size trends |
| `segment_watchdogs` | Hourly at minute 7 | Runs segment watchdog checks |
| `clear_solid_queue_finished_jobs` | Hourly at minute 12 | Clears finished queue jobs |

## HTTPS and the app host

- Production sets `assume_ssl` and `force_ssl`: run Mimeo behind a TLS-terminating proxy. Plain HTTP redirects to HTTPS.
- `APP_HOST` pins the canonical host where the owner signs in. Mimeo uses it for webhook URLs, the target of each sending domain's link CNAME and links in operator email. A bare host and a full URL both work. Without it, Mimeo captures the host from the first signed-in visit, shown under **Settings → Domains & senders**; an explicit value avoids capturing a temporary hostname.
- The proxy also serves each sending domain's link host (such as `mimeo.example.com`, a CNAME to your Mimeo) with its own certificate. Add each link host to the proxy when [Set up sending](https://mimeohq.com/docs/providers/setup) or [Domains & senders](https://mimeohq.com/docs/usage/domains-and-senders) shows it.

## Secrets

Mimeo needs one secret, `secret_key_base`. It derives the Active Record encryption keys from it, so no other encryption keys are provisioned. Provider, storage and SMTP credentials are entered in the app and stored encrypted.

| Setup | Set | Leave unset |
|---|---|---|
| Fresh install (recommended) | `SECRET_KEY_BASE`: 128 random hex characters | `RAILS_MASTER_KEY`; keep `config/master.key` and `config/credentials/*.key` out of the repo |
| Your own encrypted credentials | `RAILS_MASTER_KEY` matching your own `config/credentials/production.yml.enc`, which holds your `secret_key_base` | `SECRET_KEY_BASE` |

A random master key can't decrypt an existing credentials file. Use one setup, not a mix.

> [!CAUTION]
> Keep `secret_key_base` the same across every deploy and restore. Changing it ends every session, invalidates signed links and tracking tokens in emails already sent, and makes stored provider, storage and SMTP credentials unreadable until they're entered again in Settings. Back it up separately from the database. Never set `SECRET_KEY_BASE_DUMMY` on the running app.

## Environment variables

| Variable | Required | Default | Purpose |
|---|---|---|---|
| `RAILS_ENV` | Yes | | `production` for every process and build command |
| `SECRET_KEY_BASE` | Yes, unless using `RAILS_MASTER_KEY` | | The installation secret (see [Secrets](#secrets)) |
| `RAILS_MASTER_KEY` | Only with your own credentials file | | Decrypts `config/credentials/production.yml.enc` |
| `APP_HOST` | Recommended | Captured from the first signed-in visit | Canonical app host, bare or as a URL |
| `INERTIA_SSR` | No | `1` in production | `0` disables server-side rendering; then the `ssr` process isn't needed |
| `INERTIA_SSR_URL` | No | Port 13714 on the same server | Only if the renderer moves to another address |
| `SOLID_QUEUE_IN_PUMA` | No | Unset | Runs Solid Queue inside Puma instead of `bin/jobs` |
| `JOB_CONCURRENCY` | No | `1` | Processes for the general queue worker |
| `RAILS_MAX_THREADS` | No | `3` for Puma, `5` for the database pool | Puma threads and the database connection pool |
| `PORT` | No | `3000` | Puma's port |

## Backups

| Back up | Why |
|---|---|
| `storage/production.sqlite3` | Everything: people, events, emails, flows, sends, settings |
| `storage/uploads/` | Media, with built-in storage |
| `storage/imports/` | Only while an import is pending |
| `SECRET_KEY_BASE` | Stored apart from the database; a restore needs the same value |

- Copy the database with a SQLite-aware backup (Hatchbox SQLite backups, the SQLite backup API or Litestream), not a raw file copy while the app writes.
- Keep backups off the server and test a restore.
- A manager repo snapshot holds definitions and media only, not people or events. It isn't a backup.
- On Hatchbox: `storage/` is linked to the app's `shared/storage` on every deploy. Register `/home/deploy/<app>/shared/storage/production.sqlite3` as a database in the cluster's SQLite database cluster, then enable backups there.

## Don't deploy during a CSV import

An import stores the full path of its uploaded CSV under `storage/imports/`. Wait for running imports to finish before deploying, and keep the previous release in place until they do.

## Hatchbox specifics

| Hatchbox does | For Mimeo |
|---|---|
| Sets `RAILS_ENV` and generates `SECRET_KEY_BASE` for a new Rails app | Add `APP_HOST`; save `SECRET_KEY_BASE` in a password manager |
| Links `storage/` to `shared/storage` across releases | Nothing to configure |
| Runs `db:migrate` on the server with the **Cron** role | Give the one server both **Web** and **Cron** roles |
| Adds web (`bin/rails server`) and `bin/jobs` processes on the first deploy | Keep both; add `ssr` (`bin/vite ssr`, runs on Web, restart on every deploy) |
| Issues certificates through Caddy in **Domains & SSL** | Add the app host and each link host |

Don't attach a PostgreSQL or MySQL database to the app: attaching sets `DATABASE_URL`.

## Checklist for other Rails hosts

1. Install the runtime versions above, the Bundler and npm dependencies, and compile assets with `RAILS_ENV=production`.
2. Mount persistent storage at `storage/` before running `bin/rails db:prepare`.
3. Set `RAILS_ENV`, a unique stable `SECRET_KEY_BASE` and the real `APP_HOST`. Keep secrets out of Git and build logs.
4. Supervise the three processes on one server: Puma, `bin/jobs` and `bin/vite ssr`. Restart them on every deploy.
5. Terminate TLS at a reverse proxy for the app host and every link host. Keep ports 3000 and 13714 private.
6. Before live sending, test: the login page over HTTPS, server-rendered HTML in page source, owner signup, a completed background job, the database surviving a second deploy, and a restore from an off-server backup.

Related: [Deploy Mimeo to your server](https://mimeohq.com/docs/usage/deploy), [Run Mimeo on your own server](https://mimeohq.com/guides/run-mimeo-on-your-own-server), [Reference](https://mimeohq.com/docs/reference).

---

This is the Markdown copy of https://mimeohq.com/docs/reference/self-hosting.
