๐ง 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 โ
/home/kitchenasty/backup.sh2๏ธโฃ Step 2: Pull the Latest Code โ
cd /home/kitchenasty/kitchenasty
git pull origin main3๏ธโฃ Step 3: Rebuild and Restart โ
docker compose -f docker-compose.prod.yml up --build -d4๏ธโฃ Step 4: Run Migrations โ
If the update includes database changes:
docker compose -f docker-compose.prod.yml exec server \
npx prisma migrate deploy --schema ../../prisma/schema.prisma5๏ธโฃ Step 5: Verify โ
# 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 โ
# 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 โ
# 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 โ
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:
sudo apt update && sudo apt upgrade -y๐ณ Docker Updates โ
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:
sudo certbot renew --dry-run๐ง Troubleshooting โ
๐ซ Container Won't Start โ
# 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 โ
# 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.
# 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:
# Check memory usage
free -h
# Check per-container usage
docker stats --no-streamSolutions:
- โฌ๏ธ Upgrade your server to a larger plan
- ๐ฝ Add swap space as a temporary measure:
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 โ
- ๐ Check if the server is overloaded:
toporhtop - ๐๏ธ Check database performance: slow queries may need indexing
- ๐ฝ Check disk I/O:
iostat -x 1(install withsudo apt install sysstat) - ๐ Consider scaling: see the Scaling guide
๐ Resetting Admin Password โ
If you've lost access to the admin account:
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 โ
| Command | What It Does |
|---|---|
โถ๏ธ docker compose -f docker-compose.prod.yml up -d | Start all services |
โน๏ธ docker compose -f docker-compose.prod.yml down | Stop all services |
๐ docker compose -f docker-compose.prod.yml restart server | Restart one service |
๐ docker compose -f docker-compose.prod.yml logs -f server | Follow logs |
๐ docker compose -f docker-compose.prod.yml ps | Show service status |
๐ docker compose -f docker-compose.prod.yml exec server sh | Shell into a container |
๐จ docker compose -f docker-compose.prod.yml up --build -d | Rebuild and restart |
๐งน docker system prune -f | Clean up unused images/containers |