Fly.io Deployment

Deploy Duet to Fly.io for a managed, globally distributed setup. Fly.io handles TLS, scaling, and infrastructure so you can focus on your notes.

Prerequisites

Verify flyctl is installed:

flyctl version

Step 1: Clone the Repository

git clone https://github.com/emreparker/duet.git
cd duet

Step 2: Launch on Fly.io

The repository includes a fly.toml configuration file. Run the launch command to set up your Fly app:

fly launch

This will detect the existing fly.toml and prompt you to confirm settings. Accept the defaults or customize the app name and region.

Step 3: Create a PostgreSQL Database

Create a Fly Postgres cluster and attach it to your app:

# Create the database
fly postgres create --name duet-db

# Attach it to your app (sets DATABASE_URL automatically)
fly postgres attach duet-db

Attaching the database automatically sets the DATABASE_URL secret on your app.

Step 4: Set Secrets

Set the session secret used for signing cookies:

# Generate a random secret and set it
fly secrets set SESSION_SECRET=$(openssl rand -base64 32)

Step 5: Deploy

fly deploy

Fly will build and deploy your app. The first deploy may take a few minutes as it builds the Docker image. Subsequent deploys are faster.

Check the deployment status:

fly status

Step 6: Open Duet

Your app is now live. Open it in your browser:

fly open

Or visit https://your-app-name.fly.dev directly. Set your password on the first visit and start using Duet.

Google Calendar (Optional)

To enable Google Calendar sync, set the OAuth credentials as secrets:

fly secrets set \
  GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com \
  GOOGLE_CLIENT_SECRET=your-client-secret

Make sure your Google Cloud OAuth redirect URI is set to https://your-app-name.fly.dev/api/calendar/callback. See the Google Calendar Sync guide for full setup.

Managing Your Deployment

View Logs

fly logs

SSH into the Container

fly ssh console

Update to Latest Version

git pull
fly deploy

Connect to the Database

fly postgres connect -a duet-db

Scaling

Fly.io makes it easy to adjust resources:

# Set the number of instances
fly scale count 1

# Adjust memory (in MB)
fly scale memory 512

# Change VM size
fly scale vm shared-cpu-1x

Duet is designed to run efficiently as a single instance. For most single-user setups, the default resources are more than sufficient.

Custom Domain

To use your own domain instead of the default .fly.dev subdomain:

# Add your domain
fly certs add duet.yourdomain.com

Then add a CNAME record for your domain pointing to your Fly app. Fly automatically provisions and renews TLS certificates.

Database Backups

Fly Postgres includes daily automatic snapshots. You can also take manual snapshots:

# List existing snapshots
fly postgres snapshots list -a duet-db

# Create a manual backup using pg_dump
fly postgres connect -a duet-db -c "pg_dump -U duet duet" > backup.sql

Environment Variables Reference

VariableRequiredDescription
DATABASE_URLAutoSet automatically by fly postgres attach
SESSION_SECRETYesSecret for signing session cookies
GOOGLE_CLIENT_IDNoFor Google Calendar sync
GOOGLE_CLIENT_SECRETNoFor Google Calendar sync