Deploy guide

Palace Server on DigitalOcean (Terraform)

One terraform apply creates a droplet running Caddy and Palace Server, PostgreSQL, firewalls and the DNS record. You choose where PostgreSQL runs: DigitalOcean Managed PostgreSQL, or the droplet itself.

At a glance

WhatValue
Time to deployAbout 15 minutes with a managed database (most of it waiting for it), 5 minutes on the droplet
CostFrom $14.40/month (see below)

Where PostgreSQL runs

database =PostgreSQLBest forCost from
"managed" (default)DigitalOcean Managed PostgreSQL: daily backups and point-in-time recovery done for youTeams that want the database looked after$29.55/month
"droplet"In Docker on the droplet itself, with a nightly dumpTrials and small teams watching the bill$14.40/month
Not yet applied to a real DigitalOcean account

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. /metrics and /bootstrap are 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-full with DigitalOcean's CA).
    • droplet: PostgreSQL 18 in Docker on the droplet, reachable only by Palace on the private Compose network. A nightly pg_dump at 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.

LineSmallMedium
Droplets-1vcpu-2gb $12.00s-2vcpu-4gb $24.00
Weekly droplet backups (20%)$2.40$4.80
Total with database = "droplet"$14.40$28.80
Managed PostgreSQL1 GiB / 1 vCPU $15.152 GiB / 1 vCPU $30.45
Total with database = "managed"$29.55$59.25

Your Palace license is billed separately.

  • With managed, you can set droplet_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.
High availability (managed)

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

01

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 = false and create the A record yourself from the droplet_ip output.
  • A license key from palacememory.com.
  • Terraform 1.6+ or OpenTofu.
02

Configure

Get the recipe
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.

03

Deploy

Deploy
terraform init
terraform apply

With 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.

04

Create the first admin

Bootstrap the first admin
terraform output -raw bootstrap_command   # edit the three values, then run it

Save the api_key and org_id. The script prints the command that turns bootstrap off afterwards.

05

Connect your team

Follow Connect clients with your URL.

Upgrade

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 -d

Restore

  • managed: DigitalOcean restores a managed database to a new cluster (guide ↗). Point DATABASE_URL in /opt/palace/.env at the new cluster's private host and run docker compose up -d.
  • droplet: restore a dump from /var/backups/palace (or your off-droplet copy):
    Restore a nightly dump
    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
    Or restore the whole droplet from a DigitalOcean backup.

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 and bootstrap.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 ↗

View on GitHub ↗

Running something different?

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)

Put your knowledge to work

Give your next session
a head start.

Start your team trial

60 days · 10 seats · No credit card