Setting Up Your Database on Self-Hosted Supabase
Supabase’s open-source stack on a server you run, from a kit we give you. One paste on the server puts in Docker if it is missing, makes the stack’s secrets and starts it, and it sets up and updates its own database.
The kit is the open-source Supabase self-hosting bundle, pinned to a known version, with a small Pental overlay. It runs the portal’s database on a server of yours: a virtual machine in your Azure, Google Cloud or AWS account, or your own hardware. Your data never leaves it.
Pros and cons
Pros
- Everything runs on your own server, in your Azure, Google Cloud or AWS account or on your own hardware.
- It sets itself up: on first start the stack builds the portal’s database, with no SQL to copy anywhere.
- Updates apply themselves every day, only when Pental has signed them, and one command takes an update straight away.
- The same open-source Supabase software, Studio dashboard included.
Cons
- You run the server: the operating system, Docker, disk space, monitoring and backups are yours to look after.
- It needs a Linux server with Docker, a DNS name pointed at it and ports 80 and 443 open to the internet.
- It is one server, so the portal is up when that server is.
What you need
- A Linux server: Ubuntu, Debian, Amazon Linux, RHEL, Rocky, AlmaLinux or Fedora. Two CPUs, 4 GB of memory and 40 GB of disk suit a small firm. Docker is put on it for you if it is not there (the kit needs Docker Engine 24 and Docker Compose 2.24.4 or later, and a Compose older than that is replaced).
- A DNS name for it, such as
db.yourfirm.com, and the right to add a record for it. The setup offers one on your firm’s own domain. - Ports 80 and 443 open to the internet. Port 80 is only used to get the certificate and to redirect to 443.
- The server able to reach the internet over https: Docker for its install script and the images, Let’s Encrypt for the certificate and pental.io for the kit and schema updates.
- Your portal’s address, such as
https://yourfirm.pental.io.
Make the server
Any server that meets the list above will do. In the three big clouds, these are the choices to make, and how to open a terminal on it afterwards:
| Where | What to choose |
|---|---|
| Microsoft Azure | Create a virtual machine: Ubuntu Server 24.04 LTS, size B2s, an SSH public key with a new key pair, inbound ports SSH, HTTP and HTTPS, and on the Disks tab an OS disk of 64 GiB. Pressing Create offers the key to download: keep it. The public IP address is on the machine’s Overview. From the folder the key is in, ssh -i yourvm_key.pem azureuser@ and that address signs you in (on macOS and Linux, chmod 400 the key first). |
| Amazon Web Services | In Lightsail, Create instance: Linux/Unix, OS Only, Ubuntu 24.04 LTS and the plan with 4 GB memory and 2 vCPUs. On its Networking tab, Attach static IP, then Add rule for HTTPS (SSH and HTTP are open already). Connect using SSH opens a terminal on it in your browser, signed in as ubuntu. |
| Google Cloud | In Compute Engine, Create instance: e2-medium, a boot disk of Ubuntu 24.04 LTS at 40 GB, and Allow HTTP traffic and Allow HTTPS traffic. Then, in VPC network, IP addresses, Promote to static IP address on its external address. The SSH button beside the instance opens a terminal on it in your browser. |
| Another provider or your office | Ports 80 and 443 open in the provider’s firewall as well as the server’s, and a public IP address that stays the same. Sign in with ssh, as below. |
Point the name at the server
The name is one you choose, under a domain your firm owns, such as db.yourfirm.com: nothing needs to exist yet. At your DNS provider, add an A record for it with the server’s public IP address. Type its Name without your domain on the end (db, not db.yourfirm.com): most providers add the domain themselves, and typing it again puts the record at db.yourfirm.com.yourfirm.com, where nothing looks for it. The Database step looks the name up as you type it and says where your domain’s DNS is managed and whether the record is there yet; to check from your own computer:
Resolve-DnsName db.yourfirm.comdig +short db.yourfirm.comInstall it, in one paste
The server downloads the kit itself, so nothing needs copying across. Open a terminal on it: in your cloud’s console as above, or from PowerShell on Windows or Terminal on macOS and Linux (ssh comes with all three), with your user on the server in place of you:
ssh you@db.yourfirm.comThen, on the server, one paste does the rest: it puts in Docker if the server does not have it (and anything else the kit needs, asking for your password once if sudo wants it), downloads the kit, makes its secrets, starts it and waits for every service to come up. If the name does not lead to the server yet, it shows the A record to add, with the server’s address and the Name as your DNS provider wants it typed, and says when it is in place. The Database step writes it with your own name and portal address in. The script it runs is pental-server.sh, to read first, and Download the kit there is the kit itself.
curl -fsSL https://pental.io/downloads/pental-server.sh | sh -s -- kit db.yourfirm.com https://yourfirm.pental.ioIt writes the kit’s .env with every secret newly generated (never the example keys the whole internet knows), turns on the settings the portal needs, starts the stack and prints the two things you paste on pental.io: the address and the publishable key. It is safe to run again: it keeps what it made.
The first start downloads the images. Then, on their own, Caddy fetches a TLS certificate for your name from Let’s Encrypt and the Pental updater sets up the portal’s database with Pental’s current schema. Nobody copies SQL anywhere. To check both have happened, in the kit’s folder on the server (cd ~/pental-self-hosted-kit; until you next sign in, put sudo in front of docker):
| Run | You should see |
|---|---|
docker compose ps | Every service running or healthy |
docker compose logs pental-updater | Set up the portal schema (version …) |
curl -I https://db.yourfirm.com | An answer over https, not an error |
Connect it on pental.io
On the Database step choose Self-hosted Supabase and paste what the server printed at the end, whole: the address and the key are taken from it and the box empties itself. The setup asks your stack straight away and watches until its database is set up. Then press Check and connect: Pental checks every service the portal uses (tables, sign-in, files and live updates), plants Pental’s public keys in your stack’s vault and connects your portal.
The publishable key is the stack’s ANON_KEY, which reads nothing the security policies do not allow. Pental never asks for the service key in the same file; only a move uses it, from your own browser.
Keeping it updated
The database updates itself. When Pental publishes a new schema, the updater applies it at its daily run, 03:00 UTC unless you move it. It only applies SQL Pental has signed, checked against the key the setup planted in your own vault (before you connect, the key its first setup was checked with); anything else is refused and logged. It never applies an older version over a newer one, and an update that fails leaves the database exactly as it was.
| Run | What it does |
|---|---|
./pental-update.sh --check | Says whether an update is waiting |
./pental-update.sh | Applies it now |
docker compose logs pental-updater | Shows what the updater did, and when |
In .env, PENTAL_UPDATE_HOUR_UTC (0 to 23) moves the daily run and PENTAL_AUTO_UPDATE=false turns it off. The kit itself updates the way it installs: the same paste, in the same place, fetches the newest over its folder (your .env and your data stay as they are) and starts it again.
Keeping it safe
- Keep the server’s firewall to ports 80 and 443.
.envholds every secret. Keep a copy somewhere safe: without it, the database’s sealed secrets cannot be opened.- Studio, Supabase’s dashboard, is at your address behind the
DASHBOARD_USERNAMEandDASHBOARD_PASSWORDin.env. - Back the database up regularly. Nightly, for example:
docker compose exec -T db pg_dumpall -U postgres | gzip > backup-$(date +%F).sql.gzIf something is not right
| What you see | What to do |
|---|---|
| No certificate; the browser warns | The name does not point at the server yet, or port 80 is closed. Fix it, then run docker compose restart caddy. |
| pental.io says the portal schema is missing | docker compose logs pental-updater says why, and ./pental-update.sh tries again now. |
| pental.io says the database is on an older setup SQL | ./pental-update.sh takes the update now. Then press Check and connect again. |
| The updater cannot reach pental.io | The server needs outbound https. It tries again by itself. |
docker compose complains about !override | Docker Compose is older than 2.24.4. Paste the setup again: it puts in a current one. |
| The setup stops: a service did not start | It prints what each service that is not running said last. Put that right (most often memory: the server needs 4 GB), then paste the same line again. It keeps everything it made. |
Moving later
Move it to PostgreSQL in your cloud or Supabase Cloud whenever you like, with everything in it. The move uses the stack’s service key, which grep ^SERVICE_ROLE_KEY= .env prints in the kit’s folder.
Set It Up in the Trial
The Database step fills your server’s name into the paste and checks your stack from your browser as it starts.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, on your own server.
Also Worth Reading
Creating Your Database: Three Ways to Run It
Your portal runs end-to-end encrypted on a database you own, in one of three places: PostgreSQL in your own cloud, self-hosted Supabase, or Supabase Cloud. What each is, its pros and cons, and the full guide for each.
DatabaseSetting Up Your Database on PostgreSQL in Your Cloud
Your cloud’s own PostgreSQL on Azure, AWS or Google Cloud, or a server of yours, with the small Pental gateway beside it. One command builds it all, and it applies Pental’s signed updates itself.
DatabaseSetting Up Your Database on Supabase Cloud
A Supabase project in your own account, set up in five steps the setup checks as you go: the project, its publishable key, the setup SQL, the access token hook, then connect.