Self-Hosting Guide

Run your own Trinity infrastructure on any Linux machine, container, or cloud platform.

🚧 Coming Soon — Connect and Spirit are in active development. This guide is a preview of the planned deployment workflow.

Choosing a Deployment Option

Trinity offers two server components. Choose one (or both) depending on your environment:

OptionComponentBest ForStack
A Connect (Go) Self-hosted VPS, Raspberry Pi, Docker Go + SQLite
B Spirit (TS) Cloudflare Workers, edge/serverless TypeScript + D1
Which should I choose? If you want full control and a single binary, go with Connect. If you want zero-ops edge deployment, go with Spirit.

Option A: Trinity Connect (Self-Hosted)

Prerequisites

Build & Run

cd connect

# Set environment variables
export PORT=8080
export DB_PATH=./trinity.db

# Run the server
go run main.go

Configuration

Env VariableDefaultDescription
PORT8080HTTP port to listen on
DB_PATH./trinity.dbPath to SQLite database

API Endpoints

MethodPathDescription
POST/api/v1/dropSubmit an encrypted CSR (Blind Drop)
GET/Admin Dashboard (HTMX)

Docker Deployment

# Example Dockerfile
FROM golang:1.24-alpine AS builder
RUN apk add --no-cache gcc musl-dev
WORKDIR /app
COPY connect/ .
RUN go build -o trinity-connect .

FROM alpine:latest
COPY --from=builder /app/trinity-connect /usr/local/bin/
EXPOSE 8080
CMD ["trinity-connect"]

Reverse Proxy (Caddy)

# Caddyfile
pki.example.com {
    reverse_proxy localhost:8080
}

Caddy will automatically provision a TLS certificate from Let's Encrypt.

Litestream (Optional)

For production, use Litestream to continuously replicate your SQLite database to S3-compatible storage:

# litestream.yml
dbs:
  - path: /data/trinity.db
    replicas:
      - url: s3://my-bucket/trinity.db

Option B: Trinity Spirit (Cloudflare Workers)

Prerequisites

Setup

cd spirit

# Install dependencies
npm install

# Configure wrangler.toml with your account details
# (Update account_id and database_binding)

# Create the D1 database
wrangler d1 create trinity-spirit

# Apply the schema
wrangler d1 execute trinity-spirit --file=schema.sql

Deploy

# Deploy to Cloudflare Workers
wrangler deploy

Environment Variables

Set these via the Cloudflare dashboard or wrangler secret:

SecretDescription
ENROLLMENT_TOKENBearer token for API authentication

API Endpoints

MethodPathDescription
POST/requestsSubmit a CSR or Blind Drop
GET/certificates/:idPoll for signed certificate

Connecting Passport to Your Server

Once your server is running, configure Trinity Passport to connect to it:

  1. Open Trinity Passport and go to Settings.
  2. Enter your Spirit URL (e.g., https://pki.example.com).
  3. Enter your Enrollment Token.
  4. Click Save.

The "Submit to Cloud" button will now appear on pending identities, allowing users to submit CSRs (or encrypted Blind Drops) directly to your server.

Security Checklist

Next Steps