Sovrain
  1. Documentation
  2. Self-hosting

Tutorial

Run Sovrain on your server

Install Sovrain with Docker on a server with your own domain, create your organization, verify your email, sign in and see the trial start.

The video plays in the corner.

In this tutorial we install Sovrain on a server of our own, create the organization Acme on it and sign in as its first admin, jane. Sovrain runs in Docker behind Caddy, which gets the HTTPS certificates. At the end, Acme answers at https://acme.auth.example.com and its 30-day trial has started.

It takes about 30 minutes. Wherever you see auth.example.com, acme, 203.0.113.10 or smtp.example.com, use your own domain, short name, server address and mail server.

Before you start

You need:

  • a Linux server with Docker and Compose v2 (the docker compose command), a public IP address, and ports 80 and 443 open to the internet;
  • a domain where you can add DNS records, here example.com;
  • a mail account that sends over SMTP on port 465 with TLS, here sovrain@example.com at smtp.example.com. Sovrain uses it for the verification email in this tutorial, and later for invitations and password resets;
  • an email address you can read, for Jane.

Download the compose file

On the server, create a directory for Sovrain and download the two files of the release into it:

mkdir -p ~/sovrain && cd ~/sovrain
curl -fsSLO https://releases.sovrain.app/download/1.0.0-rc.1/docker-compose.yml
curl -fsSLO https://releases.sovrain.app/download/1.0.0-rc.1/Caddyfile

docker-compose.yml runs two containers: sovrain, the image releases.sovrain.app/sovrain, and caddy, which answers on ports 80 and 443, gets a certificate for each name and passes every request on to Sovrain. Sovrain keeps its data in the Docker volume sovrain-data.

Point DNS at the server

Sovrain needs two names: the sign-up address and the address of your organization, one level below it. Choose the organization’s short name now; here it is acme. In your DNS zone, add two A records that point at the server:

auth.example.com        A   203.0.113.10
acme.auth.example.com   A   203.0.113.10

Check that both names answer with the server’s address before you go on:

getent hosts auth.example.com acme.auth.example.com

Both lines show 203.0.113.10.

Caddy asks Let’s Encrypt for the certificates as soon as it starts, and Let’s Encrypt connects to these names to check them. If a name does not point at the server yet, Caddy keeps trying, and the browser shows a certificate error until it succeeds.

Write the configuration

Still in ~/sovrain, create the file .env. Replace the mail server, user name and password with your own:

cat > .env <<EOF
SOVRAIN_VERSION=1.0.0-rc.1
SOVRAIN_HOSTS=auth.example.com acme.auth.example.com
IDP_BASE_URL=https://auth.example.com
IDP_MEK=$(openssl rand -base64 32)
IDP_CSRF_SECRET=$(openssl rand -base64 32)
IDP_SMTP_HOST=smtp.example.com
IDP_SMTP_USERNAME=sovrain@example.com
IDP_SMTP_PASSWORD=change-me
EOF
chmod 600 .env

SOVRAIN_HOSTS tells Caddy which names to serve, and IDP_BASE_URL tells Sovrain its sign-up address. IDP_MEK is the master key: Sovrain encrypts every key and secret it stores under it. The command creates a new one each time it runs.

Run this command once. Running it again replaces IDP_MEK, and Sovrain can no longer read the data it has stored.

Start Sovrain

Start both containers and follow Sovrain’s log:

docker compose up -d
docker compose logs -f sovrain

Docker downloads the images, creates the volume and starts Sovrain. The log is one JSON object per line. Within a few seconds a line contains idp listening on 0.0.0.0:8080, data in /data. Press Ctrl+C to stop following the log; Sovrain keeps running.

Until the first organization exists, anyone who opens https://auth.example.com/register can create it. Create yours right away.

Create the organization

  1. In your browser, open https://auth.example.com/register. The form Create a new organization opens.
  2. Fill in the form:
    • Organization name: Acme
    • Organization URL: acme, the short name from the DNS step. The field ends in .auth.example.com.
    • Your email: Jane’s address. Sovrain sends the verification email there.
    • Login name: jane
    • Password and Confirm password: a password of at least 8 characters.
  3. Select Create organization and start free trial.

Your browser works for a few seconds while Please wait, we are preparing your instance… is shown; this replaces a CAPTCHA. Then Sovrain shows Your organization is ready, with the Organization URL https://acme.auth.example.com and the Login name jane.

Sign-up is now closed on this server: https://auth.example.com/register no longer opens, and more people join Acme by invitation.

Verify the email

Open Jane’s mailbox. The email from sovrain@example.com has the subject Verify your Sovrain email followed by a code. Select the link in it, which starts with https://acme.auth.example.com/verify-email.

Sovrain shows Email verified.

If the email does not arrive, look in Sovrain’s log: docker compose logs sovrain | grep Mail. A line with Mail delivery failed gives the mail server’s reason; see Configure outgoing mail. Jane can sign in without a verified email.

Sign in

  1. On the Email verified page, select Sign in, or open https://acme.auth.example.com/login. The sign-in page of Acme opens.
  2. Enter jane in Email or login name, enter the password and select Sign in.

You land on Jane’s home page, which greets you with Good morning, jane. (or afternoon, or evening). Under Your apps it says No apps yet.

See the trial

At the top of the page a banner says Your 30-day trial has started. It ends on and the date.

  1. Under Administration, select Open admin.
  2. In the admin menu, select License.

The page shows Trial with 30 days left, and under This organization the dates in trial started and trial ends.

Before the trial ends, Jane activates a license on this page; until then, Sovrain runs without one. How: Activate a license.

Keep a copy of the master key

Back on the server, show the configuration:

cat ~/sovrain/.env

Copy the whole file into your password manager. Without IDP_MEK, nobody can read Sovrain’s data again, not even from a backup. Keep this copy somewhere other than the server and its backups.

What we did

We downloaded the compose file of the release, pointed two names at the server, wrote the configuration with a new master key and started Sovrain behind Caddy. We created Acme, verified Jane’s email, signed in as Jane and saw the 30-day trial on the License page. Acme’s data is on the volume sovrain-data, and the key that opens it is in .env and in your password manager.

Next steps