# ✅ MEDIX Q - Docker Deployment Checklist

## Pre-Deployment

- [ ] Docker installed on your system
- [ ] Docker version 20.10+ (run `docker --version`)
- [ ] Docker Compose installed (run `docker-compose --version`)
- [ ] 2GB+ free disk space available
- [ ] Port 3000 is available (not in use)
- [ ] Clone/download MEDIX Q project
- [ ] Navigate to project root directory

## Verification

- [ ] Run verification script: `chmod +x verify-docker.sh && ./verify-docker.sh`
- [ ] All verification checks pass (green checkmarks)
- [ ] Docker daemon is running
- [ ] No error messages in verification output

## File Check

- [ ] `Dockerfile` exists
- [ ] `docker-compose.yml` exists
- [ ] `docker-start.sh` exists (Linux/macOS)
- [ ] `docker-start.bat` exists (Windows)
- [ ] `package.json` exists
- [ ] `pnpm-lock.yaml` exists

## Pre-Build Configuration

- [ ] Decide on deployment mode:
  - [ ] Production (optimized, built once)
  - [ ] Development (hot reload enabled)
- [ ] Port 3000 is available
  - [ ] If not, edit `docker-compose.yml` to use different port
- [ ] Sufficient disk space
  - [ ] First build may take 5-10 minutes
  - [ ] Image size: ~380MB
  - [ ] Plus node_modules: ~300MB

## Build & Start

### Option A: Using Startup Script (Recommended)

**macOS/Linux:**
- [ ] `chmod +x docker-start.sh`
- [ ] `./docker-start.sh` (production) or `./docker-start.sh dev` (development)
- [ ] Wait for "Application is running" message
- [ ] Check logs for errors: `docker-compose logs -f`

**Windows:**
- [ ] `docker-start.bat` (production) or `docker-start.bat dev` (development)
- [ ] Wait for "Application is running" message
- [ ] Check logs for errors: `docker-compose logs -f`

### Option B: Using Docker Compose

- [ ] `docker-compose up -d` (production) or `docker-compose -f docker-compose.dev.yml up` (development)
- [ ] Verify container is running: `docker-compose ps`
- [ ] Check logs: `docker-compose logs -f`
- [ ] Look for "running at http://localhost:3000"

## Post-Build Verification

- [ ] Container is running: `docker-compose ps` shows "Up"
- [ ] Health check passes: `curl http://localhost:3000/api/patients`
- [ ] No error messages in logs: `docker-compose logs`
- [ ] Data directory created: `ls -la ./data/`
- [ ] Database file exists: `ls -la ./data/medix_q.json`

## Application Verification

- [ ] Open browser: `http://localhost:3000`
- [ ] Dashboard loads without errors
- [ ] Navigation menu visible
- [ ] Patient list loads with sample data
- [ ] Queue management accessible
- [ ] All pages responsive
- [ ] No console errors (F12 to check)

## API Verification

- [ ] GET `/api/patients` returns data: `curl http://localhost:3000/api/patients | jq`
- [ ] GET `/api/queues` returns data: `curl http://localhost:3000/api/queues | jq`
- [ ] GET `/api/reports` returns data: `curl http://localhost:3000/api/reports | jq`
- [ ] All endpoints respond with HTTP 200

## Performance Check

- [ ] Dashboard loads in < 3 seconds
- [ ] Navigation between pages is smooth
- [ ] No lag or freezing observed
- [ ] Real-time updates work (queue tracking)
- [ ] Forms submit without delay

## Data Persistence

- [ ] Data survives container restart: `docker-compose restart`
- [ ] Check data still exists: `docker-compose logs -f`
- [ ] Verify database file unchanged: `stat ./data/medix_q.json`
- [ ] Create new patient and verify persistence

## Storage & Backups

- [ ] Backup data directory: `cp -r ./data ./data-backup`
- [ ] Document backup location
- [ ] Plan automated backup strategy if needed
- [ ] Document data location: `./data/medix_q.json`

## Production Deployment

If deploying to production:

- [ ] Set `NODE_ENV=production` in docker-compose.yml
- [ ] Configure appropriate resource limits
- [ ] Set up monitoring and logging
- [ ] Configure SSL/TLS if using reverse proxy
- [ ] Document deployment configuration
- [ ] Create operational runbook
- [ ] Set up health monitoring
- [ ] Plan disaster recovery

## Documentation

- [ ] Read `QUICKSTART_DOCKER.md` for quick reference
- [ ] Read `README_DOCKER.md` for complete guide
- [ ] Save `DOCKER_SETUP.md` for future reference
- [ ] Document any custom configuration
- [ ] Document team access procedures

## Common Tasks Setup

For easy future operations:

- [ ] Alias startup commands (optional):
  ```bash
  alias medix-start="./docker-start.sh"
  alias medix-stop="./docker-start.sh stop"
  alias medix-logs="docker-compose logs -f"
  ```
- [ ] Create shortcuts or scripts for common operations
- [ ] Document in team wiki/confluence

## Ongoing Maintenance

- [ ] Set up regular backups of `./data/medix_q.json`
- [ ] Monitor disk usage: `docker system df`
- [ ] Plan regular updates/rebuilds
- [ ] Monitor container health: `docker-compose ps`
- [ ] Review logs periodically: `docker-compose logs`

## Troubleshooting Setup

- [ ] Bookmark troubleshooting section: `README_DOCKER.md#troubleshooting`
- [ ] Document known issues and solutions
- [ ] Create team contact list for issues
- [ ] Save this checklist for reference

## Success Criteria

✅ Deployment is successful when:

- [ ] Application accessible at `http://localhost:3000`
- [ ] Dashboard shows real data
- [ ] All pages load and function correctly
- [ ] API endpoints respond properly
- [ ] Data persists after container restart
- [ ] No error messages in logs
- [ ] Container health check passes
- [ ] Performance is acceptable

## Rollback Plan

If issues occur:

- [ ] Stop containers: `./docker-start.sh stop`
- [ ] Restore data backup: `cp -r ./data-backup ./data`
- [ ] Check previous image: `docker images | grep medix-q`
- [ ] Rollback to previous image if needed
- [ ] Review logs for error causes
- [ ] Contact support if needed

## Post-Deployment Handoff

Before handing off to team:

- [ ] All team members can start the application
- [ ] Documentation is clear and accessible
- [ ] Basic troubleshooting documented
- [ ] Backup procedures documented
- [ ] Contact information for support
- [ ] Training session completed (if needed)

---

## Notes & Issues

**Date Started:** _____________
**Date Completed:** _____________

### Issues Encountered:
1. 
2. 
3. 

### Resolution:


### Custom Configuration Notes:


### Team Acknowledgment:
- [ ] Lead Developer: _________________ Date: _______
- [ ] System Admin: _________________ Date: _______
- [ ] Team Lead: _________________ Date: _______

---

## Quick Command Reference

```bash
# Verification
./verify-docker.sh

# Start
./docker-start.sh                           # Production
./docker-start.sh dev                       # Development

# Management
docker-compose ps                           # Status
docker-compose logs -f                      # Logs
docker-compose restart                      # Restart
docker-compose down                         # Stop

# Backup
cp -r ./data ./data-backup-$(date +%Y%m%d)

# Clean
docker-compose down -v
docker system prune -a
```

---

✅ **Checklist Complete!** MEDIX Q is ready for deployment.

For questions, see `README_DOCKER.md` or contact your team lead.
