Skip to content

๐Ÿ”ง Maintenance โ€‹

This page covers day-to-day maintenance tasks: updating to new versions, monitoring server health, and troubleshooting common issues.

๐Ÿ”„ Updating KitchenAsty โ€‹

When a new version is released, follow these steps to update:

1๏ธโƒฃ Step 1: Back Up First โ€‹

bash
/home/kitchenasty/backup.sh

2๏ธโƒฃ Step 2: Pull the Latest Code โ€‹

bash
cd /home/kitchenasty/kitchenasty
git pull origin main

3๏ธโƒฃ Step 3: Rebuild and Restart โ€‹

bash
docker compose -f docker-compose.prod.yml up --build -d

4๏ธโƒฃ Step 4: Run Migrations โ€‹

If the update includes database changes:

bash
docker compose -f docker-compose.prod.yml exec server \
  npx prisma migrate deploy --schema ../../prisma/schema.prisma

5๏ธโƒฃ Step 5: Verify โ€‹

bash
# Check all containers are healthy
docker compose -f docker-compose.prod.yml ps

# Check the API
curl -s https://api.yourdomain.com/api/health

โšก Zero-Downtime Updates

Docker Compose rebuilds and restarts containers one at a time. The downtime is typically under 30 seconds. For true zero-downtime deployments, consider using Docker Swarm or Kubernetes with rolling updates.

๐Ÿ“Š Monitoring โ€‹

๐Ÿ“ˆ Basic Monitoring with Docker โ€‹

bash
# Container status and resource usage
docker stats --no-stream

# Check container health
docker compose -f docker-compose.prod.yml ps

# View recent logs
docker compose -f docker-compose.prod.yml logs --tail 50 server

๐Ÿ’ฝ Disk Space โ€‹

bash
# Check overall disk usage
df -h

# Check Docker disk usage
docker system df

# Clean up unused Docker images (reclaim disk space)
docker system prune -f

โš ๏ธ

Run docker system prune periodically (e.g., monthly) to reclaim disk space from old images. Add the -a flag to also remove unused images, but this means the next docker compose up --build will take longer.

๐Ÿ—„๏ธ Database Size โ€‹

bash
docker compose -f docker-compose.prod.yml exec postgres \
  psql -U kitchenasty -c "SELECT pg_size_pretty(pg_database_size('kitchenasty'));"

๐ŸŒ Uptime Monitoring (External) โ€‹

Use a free uptime monitoring service to get notified if your site goes down:

  • ๐Ÿค– UptimeRobot โ€” free for up to 50 monitors
  • ๐Ÿƒ Freshping โ€” free tier available
  • ๐Ÿ  Uptime Kuma โ€” self-hosted alternative

Set up a monitor that checks https://api.yourdomain.com/api/health every 5 minutes.

๐Ÿ–ฅ๏ธ Server Maintenance โ€‹

๐Ÿ”’ Ubuntu Security Updates โ€‹

If you set up unattended upgrades during Server Setup, security patches are applied automatically. To manually check:

bash
sudo apt update && sudo apt upgrade -y

๐Ÿณ Docker Updates โ€‹

bash
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

๐Ÿ” SSL Certificate Renewal โ€‹

If using Caddy: certificates renew automatically. No action needed.

If using Nginx + Certbot: renewal is automatic via systemd timer. To verify:

bash
sudo certbot renew --dry-run

๐Ÿ”ง Troubleshooting โ€‹

๐Ÿšซ Container Won't Start โ€‹

bash
# Check logs for the failing container
docker compose -f docker-compose.prod.yml logs server

# Common causes:
# - Database not ready: wait for postgres healthcheck
# - Missing environment variable: check .env file
# - Port conflict: check if another process uses the port

๐Ÿ—„๏ธ Database Connection Errors โ€‹

bash
# Verify PostgreSQL is running
docker compose -f docker-compose.prod.yml ps postgres

# Test connection from the server container
docker compose -f docker-compose.prod.yml exec server \
  npx prisma db execute --stdin --schema ../../prisma/schema.prisma <<< "SELECT 1;"

๐Ÿ”ด "502 Bad Gateway" from Reverse Proxy โ€‹

This means the reverse proxy can't reach the backend container.

bash
# Check if containers are running
docker compose -f docker-compose.prod.yml ps

# Check if the port is listening
curl http://127.0.0.1:3000/api/health
curl http://127.0.0.1:5173
curl http://127.0.0.1:5174

๐Ÿ’พ Out of Memory โ€‹

If the server is running out of memory:

bash
# Check memory usage
free -h

# Check per-container usage
docker stats --no-stream

Solutions:

  • โฌ†๏ธ Upgrade your server to a larger plan
  • ๐Ÿ’ฝ Add swap space as a temporary measure:
bash
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# Make permanent
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

๐ŸŒ Slow Performance โ€‹

  1. ๐Ÿ“Š Check if the server is overloaded: top or htop
  2. ๐Ÿ—„๏ธ Check database performance: slow queries may need indexing
  3. ๐Ÿ’ฝ Check disk I/O: iostat -x 1 (install with sudo apt install sysstat)
  4. ๐Ÿ“ˆ Consider scaling: see the Scaling guide

๐Ÿ”‘ Resetting Admin Password โ€‹

If you've lost access to the admin account:

bash
docker compose -f docker-compose.prod.yml exec postgres \
  psql -U kitchenasty -c "
    UPDATE users SET password = '\$2a\$10\$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy'
    WHERE email = 'admin@kitchenasty.com';
  "

This resets the password to admin123. Change it immediately after logging in.

๐Ÿ“‹ Docker Compose Commands Cheat Sheet โ€‹

CommandWhat It Does
โ–ถ๏ธ docker compose -f docker-compose.prod.yml up -dStart all services
โน๏ธ docker compose -f docker-compose.prod.yml downStop all services
๐Ÿ”„ docker compose -f docker-compose.prod.yml restart serverRestart one service
๐Ÿ“‹ docker compose -f docker-compose.prod.yml logs -f serverFollow logs
๐Ÿ“Š docker compose -f docker-compose.prod.yml psShow service status
๐Ÿš docker compose -f docker-compose.prod.yml exec server shShell into a container
๐Ÿ”จ docker compose -f docker-compose.prod.yml up --build -dRebuild and restart
๐Ÿงน docker system prune -fClean up unused images/containers