Manual
Almnck.
Price: 50ⓐ

Setting Up Almanack From Scratch

This guide walks through setting up the Almanack project on a new machine.

Prerequisites

  • Python 3.10+
  • uv (recommended) or pip
  • pass (the standard Unix password manager)
  • GPG (for decrypting secrets)
  • Git LFS (binary assets — images, video, ephemeris)

On macOS:

brew install uv pass gnupg git-lfs

1. Clone the Repository

git clone <repo-url> almnck
cd almnck

2. Install Git LFS and Pull Assets

git lfs install
git lfs pull

This downloads binary assets (images, video, PDFs, ephemeris files) that are tracked via Git LFS. Without this step, you’ll have pointer files instead of actual media.

3. Set Up Secrets

The secrets/ directory is a symlink to ../almnck-secrets/, which contains encrypted passwords and credentials. You’ll need to clone or set up this separately:

cd ..
git clone <secrets-repo-url> almnck-secrets
cd almnck

Ensure your GPG key is imported and can decrypt the secrets:

gpg --import <your-key>

4. Create the Virtual Environment

python -m venv .venv --prompt almnck

5. Activate the Environment

source bin/a-activate

This sets ALMANACK_ROOT, activates the venv, and adds bin/ to PATH.

6. Install Dependencies

uv pip install -e .

Or with pip:

pip install -e .

7. Fetch JPL Ephemeris (Optional)

The celestial masthead uses JPL DE440s for accurate sun/moon positions:

make ephemeris-fetch

This downloads ~32MB to assets/reference/de440s.bsp. Only needed once. Without it, the build uses simplified astronomical formulas instead.

8. Initialize the Database

make migrate

9. Set Up the Admin Account

First, store your admin password in pass:

a-pass insert django/admin

Then create the superuser:

make ensure-admin

This reads the password from secrets/django/admin.gpg and creates (or updates) the admin superuser.

10. Sync Editorial Content

make sync

11. Build the Static Site

make build

12. Verify

Run the development server:

make serve

Visit http://localhost:1969/admin/ and log in with username danny and your admin password.

Quick Reference

After initial setup, the typical workflow is:

source bin/a-activate           # Start of session
make sync                       # After editing editorial/
make build                      # Generate static site
make serve                      # Preview locally
make prod-deploy                # Deploy to production

Production Server Setup

The production stack runs on Podman with caddy-docker-proxy for automatic HTTPS.

Prerequisites

On the server: - Podman and podman-compose - Lingering enabled for the user running containers (sudo loginctl enable-linger danny). Without this, systemd kills all rootless Podman containers when the last SSH session disconnects. - Rootless Podman socket enabled (systemctl --user enable --now podman.socket) - Unprivileged port binding from 80 (net.ipv4.ip_unprivileged_port_start=80 in sysctl) - DNS records pointing to the server: - almnck.com / www.almnck.com - static site - api.almnck.com - membership API

Directory Structure

/var/local/
├── src/almnck/          # Git repo clone
├── www/www.almnck.com/  # Static site (rsync target)
├── api/                 # Membership API data (SQLite)
└── listmonk/            # Listmonk config, secrets, and Postgres data

Initial Setup

# Clone the repo
mkdir -p /var/local/src
cd /var/local/src
git clone <repo-url> almnck

# Create directories
mkdir -p /var/local/www/www.almnck.com
mkdir -p /var/local/api

# Copy compose file
cp almnck/assets/system/docker-compose.yml ~/

Starting Services

cd ~
SERVER=sj podman-compose up -d

The $SERVER variable sets the compose project name (e.g., almanack-sj).

Services

Service Port Domain Description
caddy 80, 443 — Reverse proxy with auto-HTTPS
almnck 80 almnck.com Static site server
membership-api 8000 api.almnck.com FastAPI membership service
listmonk 9000 list.almnck.com Newsletter mailing list (see Listmonk ops)
listmonk-db 5432 — Postgres database for Listmonk

Updating

Static site (from dev machine):

make prod-deploy

Membership API (on server):

cd /var/local/src/almnck
git pull
cd ~
podman-compose up -d --build membership-api

Logs

podman-compose logs -f membership-api
podman-compose logs -f caddy

Dallas (Backup Server)

Dallas is a hot standby that mirrors the static site and membership API. It does not run Listmonk — the mailing list stays on sj only.

Since 2026-10-26 dallas also runs exodon (Danny’s ActivityPub server), so its Caddy is a shared, always-on one: a rootless podman quadlet (~/.config/containers/systemd/caddy.container) with its config in ~/caddy-config/. The almnck.com sites are a snippet in that config which is switched on only during failover.

dallas’s configuration (its Caddy, this standby’s compose file and almnck.service, the failover site, and the machine itself) is kept in Danny’s private hosts repository and deployed from there. To change it, change it there, not on dallas and not in this repository. The steps below say what that configuration does; a-failover and a-db-sync stay here.

Prerequisites

On dallas: - Podman and podman-compose - Lingering enabled: sudo loginctl enable-linger danny - Rootless Podman socket: systemctl --user enable --now podman.socket - Unprivileged ports: echo 'net.ipv4.ip_unprivileged_port_start=80' | sudo tee /etc/sysctl.d/99-unprivileged-ports.conf && sudo sysctl --system - SSH access to sj (for database sync, typically via Tailscale) - DNS records: almnck.com, www.almnck.com, api.almnck.com pointed at dallas only during failover (normally these point to sj)

Directory Structure

/var/local/
├── src/almnck/          # Git repo clone (read-only)
├── www/www.almnck.com/  # Static site (rsync target)
└── api/                 # Membership API data
    ├── .env             # Stripe keys (deployed by make prod-api-deploy)
    └── members.db       # SQLite (synced daily from sj)

Initial Setup

# Create directories
sudo mkdir -p /var/local/{src,www/www.almnck.com,api}
sudo chown danny:danny /var/local/{src,www/www.almnck.com,api}

# Clone the repo
cd /var/local/src
git clone <repo-url> almnck

# Directory for the TLS certs a-db-sync copies from sj
mkdir -p ~/caddy

# The hosts repository installs ~/docker-compose.yml and the failover
# snippet ~/caddy-config/available/almanack.caddy. Then start the services
# (almnck on 127.0.0.1:8481, API on 127.0.0.1:8482):
podman-compose up -d

almnck.service (a user unit running podman-compose up -d at boot) has a drop-in, almnck.service.d/retry.conf, with Restart=on-failure: on 2026-06-25 a boot-time pasta error made its one-shot start time out, and the standby stack stayed down for four months.

Then from the dev machine:

# Deploy API (Stripe secrets + build) to both sj and dallas
make prod-api-deploy

# Initial database sync
make prod-db-sync

Daily Sync (Database + TLS Certificates)

The bin/a-db-sync script syncs two things from sj to dallas:

  1. TLS certificates — sj’s Caddy cert storage is rsynced to ~/caddy so dallas can serve HTTPS immediately during failover, without waiting for ACME challenges. The shared Caddy mounts it read-only and loads these cert files directly in the failover snippet; its own certs (exodon) live in ~/caddy-data, out of reach of the sync’s --delete.
  2. members.db — a consistent SQLite snapshot via VACUUM INTO.

Set up as a daily cron job on dallas:

crontab -e
# Add:
0 4 * * * /var/local/src/almnck/bin/a-db-sync 2>&1 | logger -t db-sync

Failover

dallas’s shared Caddy is always running (it fronts exodon), but the almnck.com sites are off normally: an always-on Caddy would request certs for almnck.com while DNS points at sj, and fail. Failing over links ~/caddy-config/available/almanack.caddy into ~/caddy-config/failover.d/ and reloads Caddy. The snippet uses the certs synced from sj (above), so HTTPS works at once. Caddy does not renew those certs; sj renews with 30 days left, so a failover lasting longer than that needs the snippet’s tls lines removed so Caddy issues its own.

The a-failover script automates the full procedure (DNS update via Porkbun API, switching the sites on/off, health checks):

make prod-failover SERVER=dallas    # switch to dallas
make prod-failover SERVER=sj        # switch back
make prod-failover-status           # show current state

Or directly: a-failover dallas, a-failover sj, a-failover status.

The DNS abstraction layer (a-dns-update) can be swapped for another registrar by rewriting that one script.

Manual failover (if the script is unavailable):

  1. Update the A record for almnck.com to point to dallas (www and api are CNAMEs that follow automatically)
  2. Switch on the sites: ssh dallas 'ln -sf ../available/almanack.caddy ~/caddy-config/failover.d/almanack.caddy && podman exec caddy caddy reload --config /etc/caddy/Caddyfile'
  3. Stripe webhooks follow DNS — the signing secret is the same on both servers

To fail back manually:

  1. Update the A record for almnck.com back to sj
  2. Switch off the sites: ssh dallas 'rm ~/caddy-config/failover.d/almanack.caddy && podman exec caddy caddy reload --config /etc/caddy/Caddyfile'

Failover was last rehearsed on 2026-10-26 without changing DNS: sites switched on, checked over dallas’s public IP with curl --resolve (home page, www redirect, API /health, valid TLS), then switched off.

Updating

Static site updates are automatic — make prod-deploy already pushes to dallas and reloads Caddy. API updates are also automatic — make prod-api-deploy deploys to both sj and dallas.