Note: For quick setup instructions, see DEPLOYMENT.md. This guide covers advanced production deployment scenarios.
This guide provides comprehensive instructions for deploying the Simple Menu application in production environments, with emphasis on Raspberry Pi deployment with Docker and monitoring.
The Simple Menu application supports multiple deployment modes:
- Basic deployment: Application only (minimal resources)
- With monitoring: Prometheus + Grafana (recommended for production)
- Full monitoring: Unified stack with ELK + Prometheus + Grafana (high-resource environments)
- Raspberry Pi 3B+ or newer (4GB RAM recommended for monitoring)
- microSD card: 32GB+ (Class 10 or better)
- Network connection: Ethernet or WiFi
- Power supply: Official Raspberry Pi power adapter
- Docker and Docker Compose v2.0+
- Node.js 18+ (for local development)
- Git for repository management
# Update system
sudo apt update && sudo apt upgrade -y
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo usermod -aG docker $USER
# Install Docker Compose
sudo apt install docker-compose-plugin -y
# Reboot to apply changes
sudo reboot# Clone repository
git clone <repository-url> simple-menu
cd simple-menu
# Choose deployment mode:
# Basic (app only)
docker compose -f docker/docker-compose.unified.yml up -d backend frontend
# With monitoring (recommended)
./start-unified.ps1 # Windows
./start-unified.sh # Linux/macOS
# Or use Docker directly
docker compose -f docker/docker-compose.unified.yml up -dCreate .env file for custom configuration:
# Database
DATABASE_URL="file:./prisma/dev.db"
NODE_ENV=production
# Application
BACKEND_PORT=3000
FRONTEND_PORT=4200
# Monitoring (optional)
PM2_PUBLIC_KEY=your_pm2_public_key
PM2_SECRET_KEY=your_pm2_secret_key
# Performance Monitoring
GRAFANA_ADMIN_PASSWORD=admin123The application uses the unified Docker Compose configuration (docker/docker-compose.unified.yml):
services:
backend:
restart: always
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
frontend:
restart: always
depends_on:
backend:
condition: service_healthyMinimum requirements by deployment type:
| Deployment Type | RAM | Storage | CPU |
|---|---|---|---|
| Basic (app only) | 512MB | 2GB | 1 core |
| With monitoring | 2GB | 4GB | 2 cores |
| Full monitoring | 4GB | 8GB | 2+ cores |
- π¨ Alert notifications via email
- π System resource monitoring
- π‘οΈ CPU temperature monitoring (Raspberry Pi)
- π Comprehensive logging
Database backup and recovery:
# Create manual backup
./db-manager.sh backup pre-update
# List available backups
./db-manager.sh list
# Restore from backup
./db-manager.sh restore /path/to/backup.db
# Database maintenance
./db-manager.sh maintain
# Verify database health
./db-manager.sh verify
# Cleanup old backups
./db-manager.sh cleanupOnce deployed, access the application and monitoring:
- Simple Menu: http://localhost:3000 (or your server IP)
- Admin Panel: http://localhost:3000/submit
- Grafana Dashboard: http://localhost:3001 (admin/admin123) - if monitoring enabled
- Prometheus Metrics: http://localhost:9090 - if monitoring enabled
# View running services
docker compose -f docker/docker-compose.unified.yml ps
# View logs
docker compose -f docker/docker-compose.unified.yml logs -f
# Restart services
docker compose -f docker/docker-compose.unified.yml restart
# Stop all services
docker compose -f docker/docker-compose.unified.yml down
# Update and rebuild
git pull
docker compose -f docker/docker-compose.unified.yml up --build -dThe system includes built-in health checks:
# Check application health
curl http://localhost:3000/health
# Check all services
docker compose -f docker/docker-compose.unified.yml psView application logs:
# Backend logs
docker compose -f docker/docker-compose.unified.yml logs -f backend
# Frontend logs
docker compose -f docker/docker-compose.unified.yml logs -f frontend
# All logs
docker compose -f docker/docker-compose.unified.yml logs -f# Check Docker status
docker info
# Check compose file syntax
docker compose -f docker/docker-compose.unified.yml config
# View service logs
docker compose -f docker/docker-compose.unified.yml logs
# Restart services
docker compose -f docker/docker-compose.unified.yml restart# Check what's using ports
netstat -tlnp | grep -E ":(3000|4200|3001|9090)"
# Stop conflicting services
sudo systemctl stop <service-name>
# Or use different ports in docker-compose.yml# Check database file permissions
ls -la Backend/prisma/dev.db
# Reset database (development only!)
cd Backend
npx prisma migrate reset --force# Check memory usage
free -h
# Check Docker container usage
docker stats
# Reduce services (disable monitoring if needed)
docker compose -f docker/docker-compose.unified.yml up -d backend frontend# Stop all services
docker compose -f docker/docker-compose.unified.yml down
# Remove all data (careful!)
docker compose -f docker/docker-compose.unified.yml down -v
# Clean Docker system
docker system prune -f
# Rebuild from scratch
docker compose -f docker/docker-compose.unified.yml up --build -d# Create backup
cp Backend/prisma/dev.db backup/dev.db.$(date +%Y%m%d_%H%M%S)
cp -r Backend/assets backup/assets.$(date +%Y%m%d_%H%M%S)
# Restore from backup
cp backup/dev.db.YYYYMMDD_HHMMSS Backend/prisma/dev.db
cp -r backup/assets.YYYYMMDD_HHMMSS Backend/assets-
Memory Management:
# Check available memory free -h # Monitor Docker memory usage docker stats --no-stream
-
Docker Optimization:
# Set resource limits in docker-compose.yml services: backend: deploy: resources: limits: memory: 512M cpus: '1.0'
-
Database Optimization:
# SQLite optimization for Pi cd Backend npx prisma db push
The application includes several optimizations:
- Gzip compression enabled in nginx
- Browser caching for static assets
- WebSocket optimization for real-time updates
- Connection pooling for database access
-
Container Security:
- Non-root user execution
- Network isolation
- Resource limits
- Health monitoring
-
Application Security:
- Input validation
- File upload restrictions
- CORS configuration
- Rate limiting
-
Network Security:
- Internal Docker networks
- Exposed ports minimized
- Health check endpoints only
# Create complete backup
mkdir -p backup/$(date +%Y%m%d)
# Backup database
cp Backend/prisma/dev.db backup/$(date +%Y%m%d)/
# Backup uploaded assets
cp -r Backend/assets backup/$(date +%Y%m%d)/
# Backup configuration
cp docker/docker-compose.unified.yml backup/$(date +%Y%m%d)/# Setup daily backup (cron job)
0 2 * * * cd /path/to/simple-menu && mkdir -p backup/$(date +\%Y\%m\%d) && cp Backend/prisma/dev.db backup/$(date +\%Y\%m\%d)/
# Cleanup old Docker data
0 3 * * 0 docker system prune -f# Stop services
docker compose -f docker/docker-compose.unified.yml down
# Pull latest code
git pull
# Rebuild and restart
docker compose -f docker/docker-compose.unified.yml up --build -d
# Verify deployment
curl http://localhost:3000/health# Apply database changes
cd Backend
npx prisma migrate deployBefore deploying to production, verify:
- Docker and Docker Compose are properly installed
- All ports (3000, 4200, 3001, 9090) are available
- Sufficient system resources for chosen deployment mode
- Database file permissions are correct
- Network connectivity is stable
- Health checks return successful responses
- WebSocket connections work properly
- File upload functionality is tested
- Backup procedures are in place
# Deploy application
docker compose -f docker/docker-compose.unified.yml up -d
# View running services
docker compose -f docker/docker-compose.unified.yml ps
# View logs
docker compose -f docker/docker-compose.unified.yml logs -f
# Stop services
docker compose -f docker/docker-compose.unified.yml down
# Update deployment
git pull && docker compose -f docker/docker-compose.unified.yml up --build -d- Application: http://localhost:3000
- Admin Panel: http://localhost:3000/submit
- Health Check: http://localhost:3000/health
- Grafana (if enabled): http://localhost:3001
- Prometheus (if enabled): http://localhost:9090
# Check Docker status
docker info
# Check service health
curl http://localhost:3000/health
# Check container resources
docker stats
# View detailed logs
docker compose -f docker/docker-compose.unified.yml logs backendFor quick setup instructions, see DEPLOYMENT.md.
For component details, see COMPONENTS.md.
For API documentation, see API_REFERENCE.md.