Audience: Technical staff deploying KoNote to an OVHcloud VPS. Assumes: SSH access, comfort with the command line, access to a domain registrar. Read first: Deployment Index for an overview of all deployment options.
| Path | Time | Best for |
|---|---|---|
Automated (scripts/deploy-konote-vps.sh) |
~30 minutes | Production deployments, operators comfortable with SSH |
| Manual (this guide) | 45–90 minutes | Learning, troubleshooting, or when the script can't run |
The deploy script automates 9 of 15 steps below — from securing the OS through verifying the running instance. You need SSH access and a domain pointing to your VPS IP.
./scripts/deploy-konote-vps.sh \
--host YOUR_VPS_IP \
--domain konote.youragency.ca \
--admin-email admin@youragency.ca \
--org-name "Your Agency Name"The script generates all credentials, SSHes into the VPS, hardens the OS, installs Docker, clones the repo, writes .env, starts the containers, creates the admin user, and sets up backup cron jobs. It prints credentials and a post-deploy checklist at the end.
- Safe to re-run — skips already-completed steps
- Dry-run mode — add
--dry-runto preview without executing - Full options — run
./scripts/deploy-konote-vps.sh --help - Design doc — see deploy script design for architecture decisions
After the script finishes, skip to Section 7: Point Your Domain to the VPS (if DNS isn't already configured) or Section 12: Set Up External Monitoring to complete the remaining manual steps. Backups and internal monitoring are handled automatically by the ops sidecar.
Follow the full guide below step by step. This is useful for understanding what the script does, or for environments where the script can't run (e.g., non-Ubuntu servers, restricted SSH access).
This guide walks you through deploying KoNote on an OVHcloud VPS from scratch. It assumes:
- You have an OVHcloud VPS with Ubuntu 24.04 or 25.04 (fresh install)
- You have a domain name you can point to the VPS
- You are working from a Windows computer
- You have Claude Code available to help if you get stuck
Time estimate: 45–90 minutes for a first deployment (manual path).
- Connect to Your VPS via SSH
- Secure the VPS
- Install Docker
- Clone KoNote
- Generate Credentials
- Create the .env File
- Point Your Domain to the VPS
- Deploy KoNote
- Verify the Deployment
- Create Your First Admin User
- Backups and Monitoring (Automatic)
- Set Up External Monitoring
- Set Up Email (External Relay)
- Run a Second Instance (Dev/Demo)
- Updating KoNote
- Troubleshooting
When OVHcloud set up your VPS, they emailed you a password and the VPS IP address. The default username is ubuntu (not root).
Open PowerShell or Windows Terminal and type:
ssh ubuntu@YOUR_VPS_IPReplace YOUR_VPS_IP with the IP address from your OVHcloud email.
The first time you connect, you will see a message like:
The authenticity of host 'YOUR_VPS_IP' can't be established.
ED25519 key fingerprint is SHA256:abc123...
Are you sure you want to continue connecting (yes/no)?
Type yes and press Enter. Then enter your password when prompted.
Tip: The password will not show as you type -- this is normal. Just type it and press Enter.
OVHcloud forces a password change on first login. You will see:
WARNING: Your password has expired.
You must change your password now and login again!
Current password:
New password:
Retype new password:
Enter the OVHcloud-provided password as the current password, then choose a new password. OVHcloud will disconnect you after the password change -- this is normal. Reconnect with:
ssh ubuntu@YOUR_VPS_IPUse your new password this time.
Using an SSH key means you will not need to type your password every time.
Important: Complete the password change above before setting up the SSH key. The piped command below will fail if the password is still expired.
Note:
ssh-copy-idis not available on Windows. Use the manual method below.
Step 1 — Generate a key (on your local Windows machine, not the VPS):
ssh-keygen -t ed25519 -f $env:USERPROFILE\.ssh\ovh_konoteStep 2 — Copy the public key to the VPS:
type $env:USERPROFILE\.ssh\ovh_konote.pub | ssh ubuntu@YOUR_VPS_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"Enter your new password (the one you set in the previous step) when prompted.
Step 3 — Test key-based login:
ssh -i $env:USERPROFILE\.ssh\ovh_konote ubuntu@YOUR_VPS_IPThis should connect without asking for a password.
Tip: Add this to your SSH config (
~/.ssh/config) for convenience:Host konote-vps HostName YOUR_VPS_IP User ubuntu IdentityFile ~/.ssh/ovh_konoteThen just type
ssh konote-vpsto connect.
Run these commands on the VPS (you should be logged in via SSH):
sudo apt update && sudo apt upgrade -y# Allow SSH, HTTP, and HTTPS only
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw --force enable
sudo ufw statusYou should see:
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgradesSelect Yes when prompted.
# Install Docker using the official convenience script
curl -fsSL https://get.docker.com | sudo sh
# Verify Docker is running
docker --version
sudo docker compose versionYou should see version numbers for both. Docker Compose is included with modern Docker.
Note: On OVHcloud VPS, docker commands require
sudo. All docker commands in this guide usesudo.
# Create the deployment directory
sudo mkdir -p /opt/konote
cd /opt/konote
# Clone the repository
sudo git clone https://github.com/LogicalOutcomes/konote.git .Note: The
.at the end means "clone into the current directory" (not a subdirectory).
If the repository is private, you will need a GitHub Personal Access Token:
sudo git clone https://YOUR_GITHUB_TOKEN@github.com/LogicalOutcomes/konote.git .You need to generate four secret values. Run these commands on the VPS:
# Install Python cryptography library (for key generation)
sudo apt install -y python3 python3-pip
pip3 install cryptography --break-system-packages # this flag is required on Ubuntu 24.04+ — it's a Python safety check, not breaking anything
# Generate Django secret key
echo "SECRET_KEY:"
python3 -c "import secrets; print(secrets.token_urlsafe(50))"
# Generate encryption key for participant data
echo "FIELD_ENCRYPTION_KEY:"
python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
# Generate database passwords
echo "POSTGRES_PASSWORD:"
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
echo "AUDIT_POSTGRES_PASSWORD:"
python3 -c "import secrets; print(secrets.token_urlsafe(32))"Save all four values in your password manager immediately. The FIELD_ENCRYPTION_KEY is especially critical:
WARNING: If you lose the
FIELD_ENCRYPTION_KEY, all encrypted participant data (names, emails, birth dates) is permanently unrecoverable. Save a copy in your password manager and store a printed backup in a secure location.
Create the environment file with your production values:
sudo nano /opt/konote/.envPaste the following, replacing the placeholder values with your actual credentials from Step 5:
# ==============================================================================
# REQUIRED
# ==============================================================================
SECRET_KEY=PASTE_YOUR_SECRET_KEY_HERE
FIELD_ENCRYPTION_KEY=PASTE_YOUR_ENCRYPTION_KEY_HERE
# Main database
POSTGRES_USER=konote
POSTGRES_PASSWORD=PASTE_YOUR_POSTGRES_PASSWORD_HERE
POSTGRES_DB=konote
# Audit database
AUDIT_POSTGRES_USER=audit_writer
AUDIT_POSTGRES_PASSWORD=PASTE_YOUR_AUDIT_PASSWORD_HERE
AUDIT_POSTGRES_DB=konote_audit
# ==============================================================================
# DOMAIN AND SECURITY
# ==============================================================================
# Your domain name -- Caddy uses this for automatic HTTPS
DOMAIN=konote.example.ca
# Allowed hosts -- must include your domain AND localhost (for healthcheck)
ALLOWED_HOSTS=konote.example.ca,localhost
# CSRF protection -- must include https://
CSRF_TRUSTED_ORIGINS=https://konote.example.ca
# Authentication mode
AUTH_MODE=local
# Production mode -- blocks startup if security checks fail
KONOTE_MODE=production
# Demo mode -- creates demo users with quick-login buttons for staff training.
# Demo users are completely separate from real participants (is_demo=True).
# Recommended: keep this enabled so staff can train without creating fake
# participants in the real database (which would need legal tracking).
DEMO_MODE=true
# ==============================================================================
# EMAIL (OPTIONAL -- see Step 13)
# ==============================================================================
# Uncomment and configure after setting up Resend (Step 13)
# EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
# EMAIL_HOST=smtp.resend.com
# EMAIL_PORT=587
# EMAIL_USE_TLS=True
# EMAIL_HOST_USER=resend
# EMAIL_HOST_PASSWORD=re_your_resend_api_key
# DEFAULT_FROM_EMAIL=KoNote <noreply@yourdomain.ca>
# ==============================================================================
# AI FEATURES (OPTIONAL)
# ==============================================================================
# Uncomment to enable AI Goal Builder (requires OpenRouter account)
# OPENROUTER_API_KEY=sk-or-...Save the file: press Ctrl+O, then Enter, then Ctrl+X to exit nano.
Important: Replace konote.example.ca with your actual domain (e.g., konote.llewelyn.ca).
Note:
ALLOWED_HOSTSmust includelocalhost-- the Docker healthcheck pingshttp://localhost:8000/auth/login/from inside the container. Without it, the healthcheck fails and the container will be marked as unhealthy.
You need to create a DNS A record that points your domain to the VPS IP address.
- Log in to your domain registrar or DNS provider
- Go to DNS settings for your domain
- Delete any existing CNAME records for the same subdomain (e.g., if
konotehas a CNAME pointing to a previous hosting platform, delete it first). CNAME records take priority over A records and will block the new one. - Add a new record:
- Type: A
- Name:
konote(or whatever subdomain you want, e.g.,konoteforkonote.yourdomain.ca) - Value: Your VPS IP address (e.g.,
YOUR_VPS_IP) - TTL: 300 (5 minutes) or Auto
- If using Cloudflare: set the proxy status to DNS only (grey cloud, not orange). Caddy handles HTTPS directly -- Cloudflare's proxy would interfere with Let's Encrypt certificate issuance.
Important: If you previously hosted on another platform (Heroku, etc.), you likely have old CNAME records. These must be deleted before adding A records. DNS rules give CNAME priority -- if both exist, the CNAME wins and your A record will be ignored.
Wait a few minutes, then test from your local machine:
nslookup konote.yourdomain.caYou should see your VPS IP address in the response.
Note: DNS changes can take up to 48 hours to propagate globally, but usually work within 5-15 minutes for most users. Let's Encrypt uses multiple validation servers worldwide -- if some still see stale DNS, the certificate request will fail on the first attempt but Caddy retries automatically every 60 seconds until all validators see the correct IP.
Make sure you are in the KoNote directory on your VPS:
cd /opt/konoteBuild and start all containers:
sudo docker compose up -d --buildThis will:
- Build the KoNote Docker image (2-5 minutes the first time)
- Pull PostgreSQL and Caddy images
- Start all containers
- Run database migrations automatically
- Obtain a Let's Encrypt HTTPS certificate for your domain
Watch the startup progress:
sudo docker compose logs -f webYou should see:
Running migrations...
Migrations complete.
Running audit migrations...
Audit migrations complete.
Seeding data...
Running security checks...
Starting gunicorn on port 8000
Press Ctrl+C to stop watching logs (the containers keep running).
sudo docker compose psYou should see 6 containers, all with status "Up" or "Up (healthy)":
NAME SERVICE STATUS
konote-web-1 web Up (healthy)
konote-db-1 db Up (healthy)
konote-audit_db-1 audit_db Up (healthy)
konote-caddy-1 caddy Up
konote-autoheal-1 autoheal Up (healthy)
konote-ops-1 ops Up (healthy)
Note: The web container takes about 60 seconds to become healthy (it needs to run migrations and start up). If it shows "health: starting", wait a minute and check again.
Open your browser and go to:
https://konote.yourdomain.ca
You should see the KoNote login page with a valid HTTPS certificate (padlock icon in the address bar).
Caddy obtains the certificate automatically via Let's Encrypt. If DNS has not fully propagated to all of Let's Encrypt's worldwide validation servers, the first few certificate requests may fail. Check Caddy logs:
sudo docker compose logs caddyIf you see "challenge failed" errors mentioning "secondary validation", this is normal during DNS propagation. Caddy retries every 60 seconds. Once all validators see your IP, the certificate will be obtained automatically -- no action needed from you.
Check the logs:
# All container logs
sudo docker compose logs
# Just the web app
sudo docker compose logs web
# Just Caddy (HTTPS issues)
sudo docker compose logs caddySee Troubleshooting for common issues.
cd /opt/konote
sudo docker compose exec web python manage.py createsuperuserFollow the prompts to set a username and password. This creates a System Admin account that can configure the agency.
Note: The
createsuperusercommand asks for username, display name, and password. There is no email field -- KoNote uses a custom User model.
After logging in, go to Admin > Settings to:
- Set your organisation name
- Configure terminology (what you call participants, programs, etc.)
- Enable or disable features
Backups, disk monitoring, health reports, and maintenance all run automatically inside the ops sidecar container. No cron jobs to set up.
| Task | Schedule | What it does |
|---|---|---|
| Database backup | 2 AM daily | Dumps both databases, compresses, manages retention |
| Disk check | Hourly | Alerts if disk usage exceeds 80% |
| Health report | 7 AM daily | Emails operational status (no participant data) |
| Docker cleanup | 4 AM Sundays | Removes unused images and containers |
| Backup verification | 5 AM Sundays | Test-restores latest backup and verifies integrity |
All of this started when you ran docker compose up -d in Step 8. No additional setup needed.
If you used the deploy script, this is already done. If deploying manually:
sudo mkdir -p /opt/konote/backupscd /opt/konote
sudo docker compose exec ops /usr/local/bin/ops-backup.shYou should see output showing both databases being backed up with file sizes.
ls -lh /opt/konote/backups/Add these to your .env file for enhanced monitoring:
# Dead man's switch — get alerted if backups STOP running.
# Create a free push monitor at uptimerobot.com or healthchecks.io,
# then paste the URL here.
HEALTHCHECK_PING_URL=https://hc-ping.com/your-uuid-here
# Alert webhook — get notified on backup failure or disk warnings.
# Works with ntfy.sh (free), Slack, or UptimeRobot push monitors.
ALERT_WEBHOOK_URL=https://ntfy.sh/your-topic
# Daily health email — operational status emailed every morning.
# Requires email to be configured (see Step 13).
OPS_HEALTH_REPORT_TO=admin@youragency.caAfter updating .env, restart to apply:
cd /opt/konote
sudo docker compose up -dsudo docker compose logs --tail 20 opsYou should see the crontab schedule and "Ops sidecar ready. Starting crond."
If your VPS fails and you need to restore to a new server:
-
Deploy a fresh KoNote instance on a new VPS using the deploy script or this manual guide. This creates empty databases and a running application.
-
Copy your backup files from your old VPS (or wherever you saved them) to the new server:
scp main_2026-03-01_0200.dump ubuntu@NEW-VPS-IP:/opt/konote/backups/ scp audit_2026-03-01_0200.dump ubuntu@NEW-VPS-IP:/opt/konote/backups/
-
Ensure the
.envfile uses the sameFIELD_ENCRYPTION_KEYas the original instance. If the key doesn't match, encrypted participant data (names, emails, birth dates) will be unreadable. This is the key you saved in your password manager during initial deployment. -
Stop the web app to prevent writes during restore:
cd /opt/konote sudo docker compose stop web -
Restore the databases using the ops container (which has database tools and credentials pre-configured):
# Restore main database (replace filename with your backup) sudo docker compose exec -T ops bash -c \ 'PGPASSWORD="$POSTGRES_PASSWORD" pg_restore -h db -U "$POSTGRES_USER" \ -d "${POSTGRES_DB:-konote}" --clean --if-exists --no-owner \ /backups/main_2026-03-01_0200.dump' # Restore audit database sudo docker compose exec -T ops bash -c \ 'PGPASSWORD="$AUDIT_POSTGRES_PASSWORD" pg_restore -h audit_db -U "$AUDIT_POSTGRES_USER" \ -d "${AUDIT_POSTGRES_DB:-konote_audit}" --clean --if-exists --no-owner \ /backups/audit_2026-03-01_0200.dump'
-
Restart the web app:
sudo docker compose start web
-
Verify by logging in at
https://yourdomain.caand checking that participant data is visible.
Important: The
FIELD_ENCRYPTION_KEYin your.envmust match the key used when the data was originally encrypted. Without the correct key, encrypted fields (names, emails, birth dates) are permanently unrecoverable. This is why the deploy script warns you to save this key in your password manager.
Note: The
--clean --if-existsflags tell pg_restore to drop existing tables before recreating them from the backup. This is safe for a fresh deployment. The--no-ownerflag prevents permission errors when the restoring database user differs from the original.
The ops sidecar provides internal monitoring (database health, disk, backups). You should also set up external monitoring that checks your site from outside the VPS.
UptimeRobot is a free service that checks your site every 5 minutes and emails you if it goes down.
- Create a free account at uptimerobot.com
- Click Add New Monitor
- Configure:
- Monitor Type: HTTPS
- Friendly Name: KoNote Production
- URL:
https://konote.yourdomain.ca/auth/login/ - Monitoring Interval: 5 minutes
- Set up Alert Contacts (your email)
- Save
UptimeRobot will now check your site every 5 minutes and email you within minutes if it goes down.
Note: The ops sidecar monitors the system from inside (backups, disk, database health). UptimeRobot monitors from outside (is the website reachable?). You should set up both — they catch different failure modes.
OVHcloud LocalZone VPS instances block outgoing email ports (25, 587, 465). To send email (password resets, export notifications, erasure approvals), you need an external email relay service.
Resend offers 100 emails/day free, which is plenty for a small nonprofit.
- Create an account at resend.com
- Add and verify your domain (Resend will give you DNS records to add)
- Create an API key
- Update your
.envfile on the VPS:
sudo nano /opt/konote/.envUncomment and fill in the email section:
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.resend.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=resend
EMAIL_HOST_PASSWORD=re_YOUR_RESEND_API_KEY
DEFAULT_FROM_EMAIL=KoNote <noreply@yourdomain.ca>- Restart KoNote to pick up the changes:
cd /opt/konote
sudo docker compose up -dImportant: After changing
.env, you must rundocker compose up -d(notdocker compose restart). Therestartcommand does not re-read the.envfile -- onlyup -ddoes.
Brevo (formerly Sendinblue) offers 300 emails/day free.
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp-relay.brevo.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=your-brevo-email@example.com
EMAIL_HOST_PASSWORD=your-brevo-smtp-key
DEFAULT_FROM_EMAIL=KoNote <noreply@yourdomain.ca>sudo docker compose exec web python manage.py shell -c "
from django.core.mail import send_mail
send_mail('KoNote Test', 'Email is working!', None, ['your-email@example.com'])
print('Sent!')
"Check your inbox for the test email.
You can run a demo instance alongside production on the same VPS -- useful for testing, training, and showing KoNote to prospective agencies. The two instances share a single Caddy reverse proxy but have completely separate databases and encryption keys.
Internet
|
+-- konote.yourdomain.ca -----> Caddy -----> konote-web-1:8000 (production)
| |
+-- konote-dev.yourdomain.ca ---> +--------> konote-dev-web:8000 (demo)
Both web containers connect to a shared Docker network (konote-proxy) so the production Caddy can reach the dev instance. Each instance has its own databases, encryption keys, and volumes.
Add an A record for konote-dev.yourdomain.ca pointing to the same VPS IP. Follow the same process as Step 7.
sudo docker network create konote-proxyThe production instance needs a docker-compose.override.yml that connects its web and caddy containers to the shared network:
sudo nano /opt/konote/docker-compose.override.yml# Production override — connects Caddy and web to the shared proxy network
# so Caddy can reach both prod and dev web containers by container name.
# This file is automatically merged with docker-compose.yml when you run
# "docker compose up". You don't need to reference it explicitly.
services:
web:
networks:
- frontend
- backend
- konote-proxy # adds the shared network so Caddy can route to this container
caddy:
networks:
- frontend
- konote-proxy # adds the shared network so Caddy can also reach the dev container
networks:
konote-proxy:
external: true # "external" means this network already exists (created in Step 2)Apply the override:
cd /opt/konote
sudo docker compose up -dReplace the Caddyfile with one that serves both domains. Use explicit container names (not service names) to avoid DNS conflicts between the two instances:
sudo nano /opt/konote/Caddyfilekonote.yourdomain.ca {
reverse_proxy konote-web-1:8000
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-Content-Type-Options "nosniff"
Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=()"
-Server
}
encode gzip
}
konote-dev.yourdomain.ca {
reverse_proxy konote-dev-web-1:8000
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-Content-Type-Options "nosniff"
Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=()"
-Server
}
encode gzip
}
CRITICAL: Use explicit container names, never bare service names. Both instances define a
webservice. When Caddy is connected to both frontend networks, Docker DNS can resolve the bare namewebto either container unpredictably. If it resolves to the wrong one, the production site returns 404 on every page (because django-tenants doesn't recognise the domain). Usekonote-web-1andkonote-dev-web-1(the container names) to avoid this.
# Clone to a separate directory
sudo git clone https://github.com/LogicalOutcomes/konote.git /opt/konote-dev
cd /opt/konote-devGenerate new credentials (different from production):
echo "DEV_SECRET_KEY:"
python3 -c "import secrets; print(secrets.token_urlsafe(48))"
echo "DEV_FIELD_ENCRYPTION_KEY:"
python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
echo "DEV_POSTGRES_PASSWORD:"
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
echo "DEV_AUDIT_POSTGRES_PASSWORD:"
python3 -c "import secrets; print(secrets.token_urlsafe(32))"Create the dev .env:
sudo nano /opt/konote-dev/.env# KoNote Dev/Demo Instance
SECRET_KEY=PASTE_DEV_SECRET_KEY
FIELD_ENCRYPTION_KEY=PASTE_DEV_ENCRYPTION_KEY
# Main database
POSTGRES_USER=konote_dev
POSTGRES_PASSWORD=PASTE_DEV_POSTGRES_PASSWORD
POSTGRES_DB=konote_dev
# Audit database
AUDIT_POSTGRES_USER=audit_dev
AUDIT_POSTGRES_PASSWORD=PASTE_DEV_AUDIT_PASSWORD
AUDIT_POSTGRES_DB=konote_dev_audit
# Domain
DOMAIN=konote-dev.yourdomain.ca
ALLOWED_HOSTS=konote-dev.yourdomain.ca,localhost
CSRF_TRUSTED_ORIGINS=https://konote-dev.yourdomain.ca
# Auth and mode
AUTH_MODE=local
KONOTE_MODE=demo
DEMO_MODE=true
# Email (console backend -- demo doesn't need real email)
DEFAULT_FROM_EMAIL=KoNote Dev <noreply@konote.app>
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
EMAIL_PORT=587
EMAIL_USE_TLS=Truesudo nano /opt/konote-dev/docker-compose.override.yml# Dev instance override — gives each container a unique name, disables its own
# Caddy (production Caddy handles both domains), and uses separate database
# volumes so dev data is completely isolated from production.
services:
web:
container_name: konote-dev-web # unique name so Caddy can address it directly
ports: !reset [] # removes the host port mapping from the base file
# (Caddy reaches this container via Docker network instead)
networks:
- frontend
- backend
- konote-proxy # shared network so production Caddy can reach this container
db:
container_name: konote-dev-db
volumes:
- dev_pgdata:/var/lib/postgresql/data # separate volume — dev data stays isolated from prod
audit_db:
container_name: konote-dev-audit-db
volumes:
- dev_audit_pgdata:/var/lib/postgresql/data
- ./scripts/audit_db_init.sql:/docker-entrypoint-initdb.d/01-init.sql
caddy:
profiles:
- disabled # disables this container — production Caddy handles both domains
autoheal:
container_name: konote-dev-autoheal
volumes:
dev_pgdata: # separate named volumes prevent data mixing
dev_audit_pgdata:
networks:
konote-proxy:
external: true # connects to the shared network created in Step 2Key details:
ports: !reset []removes the host port mapping (Caddy reaches it via Docker network)caddy: profiles: [disabled]disables the dev's own Caddy (production Caddy handles both domains)- Separate volume names (
dev_pgdata,dev_audit_pgdata) keep data isolated from production - Unique container names prevent conflicts
cd /opt/konote-dev
sudo docker compose up -d --buildcd /opt/konote
sudo docker compose exec caddy caddy reload --config /etc/caddy/Caddyfile# Check all containers
sudo docker compose -f /opt/konote/docker-compose.yml ps
sudo docker compose -f /opt/konote-dev/docker-compose.yml psYou should see 9 containers total (5 prod + 4 dev).
Open https://konote-dev.yourdomain.ca in your browser. You should see the login page with demo quick-login buttons that let you switch between different roles without passwords.
Note: Caddy provisions the dev certificate separately. If DNS is still propagating for the dev subdomain, the certificate may take a few minutes to appear. Caddy retries automatically.
When a new version is released:
- Back up both databases — in case the update introduces problems:
sudo /opt/konote/scripts/backup-vps.sh- Note the current commit — so you can roll back if needed:
cd /opt/konote
sudo git log --oneline -1
# Example output: a1b2c3d Fix dashboard layoutSave that commit hash (e.g., a1b2c3d). You'll need it if you want to undo the update.
Recommended: Use the deploy script (updates, rebuilds, and health-checks in one command):
# Production only
/opt/konote/deploy.sh
# Dev only
/opt/konote/deploy.sh --dev
# Both production and dev
/opt/konote/deploy.sh --allThe deploy script (scripts/deploy.sh) pulls develop, rebuilds the web container, restarts, and waits for the health check. For the dev instance, it also auto-resets the database if migrations fail — this is safe because the dev instance only has demo data (DEMO_MODE=true).
Manual alternative (if the deploy script is not installed yet):
cd /opt/konote
# Pull the latest code
sudo git pull origin main
# Rebuild and restart (migrations run automatically on startup)
sudo docker compose up -d --buildThe entrypoint script handles database migrations automatically. Downtime is typically under 2 minutes.
- Visit your KoNote URL — the login page should load
- Log in and check a few pages (dashboard, a client page, a report)
- Check container health:
sudo docker compose ps— all should show "healthy"
If the update breaks your instance:
cd /opt/konote
# Revert to the previous commit
sudo git checkout a1b2c3d -- .
# (Replace a1b2c3d with the hash you saved before updating)
# Rebuild with the old code
sudo docker compose up -d --buildIf the broken update ran database migrations (new tables or columns), you may also need to restore from the backup you took. See Troubleshooting: Restore from backup below.
For detailed procedures, see the Update and Rollback Guide.
The dev instance uses DEMO_MODE=true and only contains demo data. When the deploy script detects a migration failure on the dev instance (e.g., because the dev database was created from an older branch), it automatically:
- Stops the web container
- Drops and recreates both databases (main + audit)
- Restarts the web container (which auto-migrates and re-seeds demo data)
This means the dev instance always comes back to a working state after a deploy, even if the database schema is completely out of sync. Production never auto-resets — it fails loudly so you can investigate.
If you need to manually reset the dev database:
cd /opt/konote-dev
docker compose stop web
docker compose exec -T db psql -U konote_dev -d postgres \
-c "DROP DATABASE IF EXISTS konote_dev;" \
-c "CREATE DATABASE konote_dev OWNER konote_dev;"
docker compose exec -T audit_db psql -U audit_dev -d postgres \
-c "DROP DATABASE IF EXISTS konote_dev_audit;" \
-c "CREATE DATABASE konote_dev_audit OWNER audit_dev;"
docker compose up -d web
# Wait ~60s for migrations + seed to complete, then check health
docker compose ps- Check containers are running:
sudo docker compose ps - Check firewall:
sudo ufw status-- ports 80 and 443 must be open - Check DNS:
nslookup konote.yourdomain.cafrom your local machine -- must show VPS IP - Check Caddy logs:
sudo docker compose logs caddy-- look for certificate errors
Django is rejecting the request because the domain is not in ALLOWED_HOSTS. Common causes:
- The domain in
.envdoesn't match the URL you're visiting localhostis missing fromALLOWED_HOSTS(needed for Docker healthcheck)- You're running two instances and the wrong one is receiving traffic (check Caddyfile uses explicit container names)
Fix: edit .env, update ALLOWED_HOSTS, then run sudo docker compose up -d.
If all URLs on the production domain return 404 but the dev domain works fine, Caddy is routing production traffic to the dev web container. This happens because of a Docker DNS conflict:
- Both instances define a
webservice - When Caddy is connected to both frontend networks, Docker DNS can resolve
webto the dev container instead of production - The dev container doesn't recognise the production domain, so django-tenants returns 404
Fix:
- Check the Caddyfile uses explicit container names (not bare service names):
# Wrong — ambiguous when multiple instances share a network
reverse_proxy web:8000
# Correct — unambiguous container name
reverse_proxy konote-web-1:8000
- Edit the Caddyfile on the VPS:
sudo nano /opt/konote/Caddyfile- Restart Caddy to pick up the change:
sudo docker restart konote-caddy-1Note: The deploy script preserves the Caddyfile across deploys (it backs up and restores custom Caddyfiles that differ from the repo template). You can also protect it manually with
git update-index --skip-worktree Caddyfile.
The web container is not ready yet or has crashed:
sudo docker compose logs webLook for error messages. Common causes:
- Missing environment variable (check
.env) - Database not ready (wait 30 seconds and try again)
- Security check failed (check
KONOTE_MODEsetting)
The CSRF_TRUSTED_ORIGINS in .env does not match your domain. It must include https://:
# Correct
CSRF_TRUSTED_ORIGINS=https://konote.yourdomain.ca
# Wrong
CSRF_TRUSTED_ORIGINS=konote.yourdomain.caAfter fixing, restart: sudo docker compose up -d
After editing .env, you must run:
sudo docker compose up -dDo not use docker compose restart -- it does not re-read the .env file. Only docker compose up -d recreates containers with the new environment variables.
- DNS must point to the VPS before starting Caddy
- Port 80 must be open (Let's Encrypt uses HTTP-01 challenge)
- Old CNAME records must be deleted (they take priority over A records)
- If using Cloudflare: set proxy to DNS only (grey cloud)
- Check Caddy logs:
sudo docker compose logs caddy
If you see "challenge failed" with "secondary validation" errors, this means some of Let's Encrypt's worldwide validators still see old DNS. Caddy retries every 60 seconds -- no action needed. This resolves within minutes to hours as DNS propagates.
Check what is failing:
sudo docker compose logs --tail 50 webIf you see "security check failed", the app is in production mode and a required setting is missing. Either fix the setting or temporarily set KONOTE_MODE=demo in .env to start with warnings instead of hard failures.
# Check disk usage
df -h /
# Remove old Docker images
sudo docker system prune -f
# Check backup sizes
du -sh /opt/konote/backups/If you need to restore a database from backup:
# Stop the web container (keep databases running)
sudo docker compose stop web
# Restore main database
gunzip -c /opt/konote/backups/main_2026-03-01_0200.sql.gz | \
sudo docker compose exec -T db psql -U konote konote
# Restore audit database
gunzip -c /opt/konote/backups/audit_2026-03-01_0200.sql.gz | \
sudo docker compose exec -T audit_db psql -U audit_writer konote_audit
# Restart the web container
sudo docker compose start web| Task | Command |
|---|---|
| Start KoNote | cd /opt/konote && sudo docker compose up -d |
| Stop KoNote | cd /opt/konote && sudo docker compose down |
| View logs | cd /opt/konote && sudo docker compose logs -f web |
| Restart after .env change | cd /opt/konote && sudo docker compose up -d |
| Rebuild after code update | cd /opt/konote && sudo git pull && sudo docker compose up -d --build |
| Create admin user | sudo docker compose exec web python manage.py createsuperuser |
| Run backup now | sudo docker compose exec ops /usr/local/bin/ops-backup.sh |
| Ops logs | sudo docker compose logs --tail 50 ops |
| Check container health | sudo docker compose ps |
| Check disk space | df -h / |
| View backup files | ls -lh /opt/konote/backups/ |
| SSH to VPS | ssh -i ~/.ssh/ovh_konote ubuntu@YOUR_VPS_IP |