# Render

> Deploy an app on Render from the repository's Blueprint, and what it costs.

Render can create the app and its Postgres database from a Blueprint, a `render.yaml` file in the repository that lists the services to create. The repository has two:

- `render.yaml` at the repository root: every app (currently the Scheduler and Invoicing), each with its own database.
- `apps/scheduler/render.yaml`: the Scheduler only.

## Cost

The Blueprints use paid plans, because the apps need an always-on process to send reminders on time. At the time of writing, a Starter web service is about $7 per month and the smallest paid Postgres (Basic-256mb) about $6 per month, so roughly **$13 per month per app**, plus any workspace fees. The root Blueprint creates both apps, so about $26 per month. Check [render.com/pricing](https://render.com/pricing) before you deploy.

Render's free tier doesn't work for these apps:

- Free web services spin down after 15 minutes without traffic, so reminders and recurring invoices run late or not at all.
- Free Postgres databases expire 30 days after creation.
- Free web services can't send email on ports 25, 465 or 587.
- Like every Render service, the local filesystem is wiped on each deploy.

## Before you start

- A Render account and a payment method.
- Your own copy of the repository on GitHub. Fork https://github.com/gtalarico/saas-clones so you decide when to take updates, and so you can edit the Blueprint.
- Your email provider's SMTP settings (see the [email guide](./email.md)).
- An S3-compatible bucket for uploads, such as Cloudflare R2 (see [Uploads on Render](#uploads-on-render)).

## Deploy the Scheduler

1. In the Render Dashboard, go to **New > Blueprint**.
2. Click **Connect** next to your fork. You may need to connect your GitHub account first.
3. Name the Blueprint and choose the `main` branch.
4. In **Blueprint Path**, enter `apps/scheduler/render.yaml`.
5. Fill in the values Render asks for:
   - `APP_URL`: the address the app will have. If you don't have a custom domain yet, enter `https://scheduler.onrender.com` for now; you'll correct it after the first deploy.
   - `SMTP_URL`: from your email provider.
6. Review the changes Render will apply (one web service, one database), then click **Deploy Blueprint**.

`DATABASE_URL` is wired to the new database and `AUTH_SECRET` is generated for you.

## Deploy Invoicing

The root `render.yaml` contains every app. To deploy only Invoicing, edit `render.yaml` in your fork first: delete the `scheduler` entry under `services` and the `scheduler-db` entry under `databases`, and commit. Then follow the steps above, leaving **Blueprint Path** empty. Render asks for `APP_URL`, `SMTP_URL`, `STRIPE_SECRET_KEY` and `STRIPE_WEBHOOK_SECRET`. Leave the Stripe values empty if you're not using Stripe yet (see the [Stripe guide](./stripe.md)).

## After the first deploy

1. Open the web service in the dashboard and copy its address (`https://<name>.onrender.com`, sometimes with a random suffix).
2. In the service's environment settings, set `APP_URL` to that address (or to your custom domain) and save. Render redeploys.
3. Add the other variables you need, such as `EMAIL_FROM`, the storage variables below, or `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`. The full list is on the app page ([Scheduler](./scheduler.md#environment-variables), [Invoicing](./invoicing.md#environment-variables)).
4. Check the app:

   ```sh
   curl -fsS https://<your-address>/api/health
   # {"ok":true,"db":true,"version":"dev"}
   ```

5. Open `https://<your-address>/setup` and create the admin account. See [first admin](./first-admin.md).

The Blueprints already set the health check path to `/api/health`.

## Uploads on Render

The Blueprints don't set up storage, so uploaded logos and profile photos land on the service's disk and are lost on the next deploy. Use an S3-compatible bucket: set `STORAGE_DRIVER=s3` and the `S3_*` variables from the [storage guide](./storage.md). Cloudflare R2 is a good fit because it has a free allowance and no egress fees.

Render also sells persistent disks for paid services. A disk stops zero-downtime deploys and limits the service to one instance. If you try one, mount it at `/app/data` and set `STORAGE_LOCAL_DIR=/app/data/uploads`. The app runs as a non-root user, so if uploads fail with a permission error, use a bucket instead.

## Custom domain

Add the domain in the web service's settings and create the DNS records Render shows. Then set `APP_URL` to the new address, and update the Google redirect URIs and Stripe webhook URL if you use them.

## Updating

Render redeploys when the linked branch of your fork changes. Sync your fork with the upstream repository on GitHub to take a new version. Migrations run on startup. See [updates and backups](./updates-backups.md).

## Troubleshooting

- **Deploy fails its health check:** open the service logs. `Invalid configuration` lists missing or wrong variables.
- **Sign-in fails:** `APP_URL` doesn't match the address in your browser. Fix it and redeploy.
- **Emails time out:** check that the service is on a paid plan (free services can't use SMTP ports) and that `SMTP_URL` is correct.