At a glance
| What | Value |
|---|---|
| Time to deploy | About 15 minutes with a managed database (most of it waiting for it), 5 minutes on the droplet |
| Cost | From $14.40/month (see below) |
Where PostgreSQL runs
| database = | PostgreSQL | Best for | Cost from |
|---|---|---|---|
"managed" (default) | DigitalOcean Managed PostgreSQL: daily backups and point-in-time recovery done for you | Teams that want the database looked after | $29.55/month |
"droplet" | In Docker on the droplet itself, with a nightly dump | Trials and small teams watching the bill | $14.40/month |
The Terraform passes validation and the cloud-init it renders was run locally in both modes, but a full apply against a real DigitalOcean account has not run yet. The Tested section below lists what was checked.
What this sets up
- A droplet (Ubuntu 24.04) running Caddy (automatic HTTPS) and Palace Server as non-root with a read-only filesystem and no capabilities.
/metricsand/bootstrapare not reachable from outside. - PostgreSQL with pgvector. Palace connects as
palace_app, a role that cannot bypass row-level security.managed: a single-node Managed PostgreSQL on a private VPC. Only the droplet may connect, over TLS (sslmode=verify-fullwith DigitalOcean's CA).droplet: PostgreSQL 18 in Docker on the droplet, reachable only by Palace on the private Compose network. A nightlypg_dumpat 03:15 keeps 7 days of dumps in/var/backups/palace.
- A cloud firewall: SSH only from your addresses, 80 and 443 from everywhere.
- An A record in DigitalOcean DNS (optional).
Costs
Prices checked 2026-11-29, USD per month before tax. Droplets ↗, Managed databases ↗, DNS is free.
| Line | Small | Medium |
|---|---|---|
| Droplet | s-1vcpu-2gb $12.00 | s-2vcpu-4gb $24.00 |
| Weekly droplet backups (20%) | $2.40 | $4.80 |
Total with database = "droplet" | $14.40 | $28.80 |
| Managed PostgreSQL | 1 GiB / 1 vCPU $15.15 | 2 GiB / 1 vCPU $30.45 |
Total with database = "managed" | $29.55 | $59.25 |
Your Palace license is billed separately.
- With
managed, you can setdroplet_backups = false: the database has its own backups. - With
droplet, keep droplet backups on. They are weekly, so also copy the nightly dumps off the droplet (for example to a Spaces bucket) if you can't afford to lose up to a week.
From 30 November 2026, DigitalOcean's Standard database plans cannot add standby nodes or go above 4 GiB RAM (DigitalOcean docs ↗). For a standby you need their Advanced Edition, which starts at $130/month. This recipe uses a single Standard node.
Steps
Prepare
- A DigitalOcean API token:
export DIGITALOCEAN_TOKEN=... - An SSH key in your DigitalOcean account (its fingerprint).
- Your domain added to DigitalOcean DNS, or set
manage_dns = falseand create the A record yourself from thedroplet_ipoutput. - A license key from palacememory.com.
- Terraform 1.6+ or OpenTofu.
Configure
git clone https://github.com/AncientiCe/palace-server-examples.git
cd palace-server-examples/digitalocean
cp terraform.tfvars.example terraform.tfvars # edit it, including database =
export TF_VAR_license_key='your-license-key'Terraform state holds the generated secrets (database passwords, JWT secret). For anything beyond a trial, keep state in an encrypted remote backend such as a private DigitalOcean Spaces bucket.
Deploy
terraform init
terraform applyWith managed, the droplet waits for the database, creates the extensions and the palace_app role, then starts Palace. With droplet, PostgreSQL starts next to Palace and sets itself up on first start. Give it a few minutes after apply finishes, then open https://<your domain>/readyz.
Create the first admin
terraform output -raw bootstrap_command # edit the three values, then run itSave the api_key and org_id. The script prints the command that turns bootstrap off afterwards.
Connect your team
Follow Connect clients with your URL.
Upgrade
ssh root@<droplet_ip>
cd /opt/palace
nano docker-compose.yml # set the new tag in ghcr.io/ancientice/palace-server:<version>
docker compose pull && docker compose up -dRestore
- managed: DigitalOcean restores a managed database to a new cluster (guide ↗). Point
DATABASE_URLin/opt/palace/.envat the new cluster's private host and rundocker compose up -d. - droplet: restore a dump from
/var/backups/palace(or your off-droplet copy):Or restore the whole droplet from a DigitalOcean backup.cd /opt/palace docker compose stop palace-server docker compose exec -T postgres pg_restore -U palace -d palace --clean --if-exists < /var/backups/palace/palace-YYYY-MM-DD.dump docker compose up -d
Tested
The Terraform passes terraform validate in both modes. The cloud-init it renders was run locally for both:
managed: the database setup (twice, to check it is safe to re-run), the Compose stack, HTTPS through Caddy, the blocked paths andbootstrap.sh.droplet: the Compose stack with PostgreSQL, HTTPS through Caddy,bootstrap.sh, storing a memory and search, and the nightly dump command.
A full apply against a real DigitalOcean account has not run yet. If verify-full fails against your managed cluster's certificate, set db_sslmode = "verify-ca" and open an issue ↗.
Troubleshooting
- Site not up after a few minutes:
ssh root@<ip> 'tail -50 /var/log/cloud-init-output.log' - Palace restarting:
ssh root@<ip> 'cd /opt/palace && docker compose logs palace-server' - Something else? Open an issue ↗
Nomad, Hetzner, OpenShift, another IaC tool? Request a setup ↗. Never paste license keys, passwords, tokens or database URLs in an issue.
Other setups
Docker Compose on one machine · AWS (Terraform, ECS Fargate + RDS) · Google Cloud (Terraform, Cloud Run + Cloud SQL) · Azure (Terraform, Container Apps + PostgreSQL Flexible Server) · Kubernetes (Helm) · Kubernetes (plain kubectl) · Air-gapped (no internet) · Linux without Docker (systemd)