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
- flyctl - install from fly.io/docs/flyctl/install
- Fly.io account - sign up at fly.io
Verify flyctl is installed:
flyctl versionStep 1: Clone the Repository
git clone https://github.com/emreparker/duet.git
cd duetStep 2: Launch on Fly.io
The repository includes a fly.toml configuration file. Run the launch command to set up your Fly app:
fly launchThis 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-dbAttaching 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 deployFly 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 statusStep 6: Open Duet
Your app is now live. Open it in your browser:
fly openOr 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-secretMake 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 logsSSH into the Container
fly ssh consoleUpdate to Latest Version
git pull
fly deployConnect to the Database
fly postgres connect -a duet-dbScaling
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-1xDuet 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.comThen 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.sqlEnvironment Variables Reference
| Variable | Required | Description |
|---|---|---|
| DATABASE_URL | Auto | Set automatically by fly postgres attach |
| SESSION_SECRET | Yes | Secret for signing session cookies |
| GOOGLE_CLIENT_ID | No | For Google Calendar sync |
| GOOGLE_CLIENT_SECRET | No | For Google Calendar sync |