Backup: 2025-07-21 18:13 - I got Claude Code
Some checks failed
CI/CD Pipeline / Backend Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Tests (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
E2E Tests / E2E Tests - ${{ github.event.inputs.environment || 'staging' }} (push) Has been cancelled
E2E Tests / Notify Results (push) Has been cancelled
Dependency Updates / Update Dependencies (push) Has been cancelled

[Restore from backup: vip-coordinator-backup-2025-07-21-18-13-I got Claude Code]
This commit is contained in:
2025-07-21 18:13:00 +02:00
parent 36cb8e8886
commit 8ace1ab2c1
33 changed files with 3507 additions and 3656 deletions

View File

@@ -1,232 +1,266 @@
# 🚀 VIP Coordinator - Docker Hub Deployment Guide
## 📋 Quick Start
Deploy the VIP Coordinator application on any system with Docker in just a few steps!
### Prerequisites
- Docker and Docker Compose installed
- Google Cloud Console account (for OAuth setup)
## 📋 Prerequisites
### 1. Download and Configure
- **Docker** and **Docker Compose** installed on your system
- **Domain name** (optional, can run on localhost for testing)
- **Google Cloud Console** account for OAuth setup
## 🚀 Quick Start (5 Minutes)
### 1. Download Deployment Files
Create a new directory and download these files:
```bash
# Pull the project
git clone <your-dockerhub-repo-url>
mkdir vip-coordinator
cd vip-coordinator
# Copy environment template
cp .env.example .env.prod
# Edit with your configuration
nano .env.prod
# Download the deployment files
curl -O https://raw.githubusercontent.com/your-repo/vip-coordinator/main/docker-compose.yml
curl -O https://raw.githubusercontent.com/your-repo/vip-coordinator/main/.env.example
```
### 2. Required Configuration
Edit `.env.prod` with your values:
### 2. Configure Environment
```bash
# Database Configuration
DB_PASSWORD=your-secure-database-password
# Copy the environment template
cp .env.example .env
# Domain Configuration (update with your domains)
DOMAIN=your-domain.com
VITE_API_URL=https://api.your-domain.com/api
# Google OAuth Configuration (from Google Cloud Console)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=https://api.your-domain.com/auth/google/callback
# Frontend URL
FRONTEND_URL=https://your-domain.com
# Admin Configuration
ADMIN_PASSWORD=your-secure-admin-password
# Edit the configuration (use your preferred editor)
nano .env
```
### 3. Google OAuth Setup
**Required Changes in `.env`:**
- `DB_PASSWORD`: Change to a secure password
- `ADMIN_PASSWORD`: Change to a secure password
- `GOOGLE_CLIENT_ID`: Your Google OAuth Client ID
- `GOOGLE_CLIENT_SECRET`: Your Google OAuth Client Secret
1. **Create Google Cloud Project**:
- Go to [Google Cloud Console](https://console.cloud.google.com/)
- Create a new project
**For Production Deployment:**
- `DOMAIN`: Your domain name (e.g., `mycompany.com`)
- `VITE_API_URL`: Your API URL (e.g., `https://api.mycompany.com`)
- `GOOGLE_REDIRECT_URI`: Your callback URL (e.g., `https://api.mycompany.com/auth/google/callback`)
- `FRONTEND_URL`: Your frontend URL (e.g., `https://mycompany.com`)
2. **Enable Google+ API**:
- Navigate to "APIs & Services" > "Library"
- Search for "Google+ API" and enable it
### 3. Set Up Google OAuth
3. **Create OAuth Credentials**:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth 2.0 Client IDs"
- Application type: "Web application"
- Authorized redirect URIs: `https://api.your-domain.com/auth/google/callback`
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select existing one
3. Enable the Google+ API
4. Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs"
5. Set application type to "Web application"
6. Add authorized redirect URIs:
- For localhost: `http://localhost:3000/auth/google/callback`
- For production: `https://api.your-domain.com/auth/google/callback`
7. Copy the Client ID and Client Secret to your `.env` file
### 4. Deploy
### 4. Deploy the Application
```bash
# Pull the latest images from Docker Hub
docker-compose pull
# Start the application
docker-compose -f docker-compose.prod.yml up -d
docker-compose up -d
# Check status
docker-compose -f docker-compose.prod.yml ps
# View logs
docker-compose -f docker-compose.prod.yml logs -f
docker-compose ps
```
### 5. Access Your Application
### 5. Access the Application
- **Frontend**: http://your-domain.com (or http://localhost if running locally)
- **Backend API**: http://api.your-domain.com (or http://localhost:3000)
- **API Documentation**: http://api.your-domain.com/api-docs.html
- **Local Development**: http://localhost
- **Production**: https://your-domain.com
### 6. First Login
- Visit your frontend URL
- Click "Continue with Google"
- The first user becomes the system administrator
- Subsequent users need admin approval
## 🔧 Configuration Details
## 🔧 Configuration Options
### Environment Variables
| Variable | Required | Description | Example |
|----------|----------|-------------|---------|
| `DB_PASSWORD` | ✅ | PostgreSQL database password | `SecurePass123!` |
| `DOMAIN` | ✅ | Your main domain | `example.com` |
| `VITE_API_URL` | ✅ | API endpoint URL | `https://api.example.com/api` |
| `GOOGLE_CLIENT_ID` | ✅ | Google OAuth client ID | `123456789-abc.apps.googleusercontent.com` |
| `GOOGLE_CLIENT_SECRET` | ✅ | Google OAuth client secret | `GOCSPX-abcdef123456` |
| `GOOGLE_REDIRECT_URI` | ✅ | OAuth redirect URI | `https://api.example.com/auth/google/callback` |
| `FRONTEND_URL` | ✅ | Frontend URL | `https://example.com` |
| `ADMIN_PASSWORD` | ✅ | Admin panel password | `AdminPass123!` |
| Variable | Description | Required | Default |
|----------|-------------|----------|---------|
| `DB_PASSWORD` | PostgreSQL database password | ✅ | - |
| `ADMIN_PASSWORD` | Admin interface password | ✅ | - |
| `GOOGLE_CLIENT_ID` | Google OAuth Client ID | ✅ | - |
| `GOOGLE_CLIENT_SECRET` | Google OAuth Client Secret | ✅ | - |
| `GOOGLE_REDIRECT_URI` | OAuth callback URL | ✅ | - |
| `FRONTEND_URL` | Frontend application URL | ✅ | - |
| `VITE_API_URL` | Backend API URL | ✅ | - |
| `DOMAIN` | Your domain name | ❌ | localhost |
| `AVIATIONSTACK_API_KEY` | Flight data API key | ❌ | - |
| `PORT` | Backend port | ❌ | 3000 |
### Optional Configuration
### Ports
- **AviationStack API Key**: Configure via admin interface for flight tracking
- **Custom Ports**: Modify docker-compose.prod.yml if needed
- **Frontend**: Port 80 (HTTP)
- **Backend**: Port 3000 (API)
- **Database**: Internal only (PostgreSQL)
- **Redis**: Internal only (Cache)
## 🏗️ Architecture
## 🌐 Production Deployment
### Services
- **Frontend**: React app served by Nginx (Port 80)
- **Backend**: Node.js API server (Port 3000)
- **Database**: PostgreSQL with automatic schema setup
- **Redis**: Caching and real-time updates
### With Reverse Proxy (Recommended)
### Security Features
- JWT tokens with automatic key rotation (24-hour cycle)
- Non-root containers for enhanced security
- Health checks for all services
- Secure headers and CORS configuration
For production, use a reverse proxy like Nginx or Traefik:
## 🔐 Security Best Practices
```nginx
# Nginx configuration example
server {
listen 80;
server_name your-domain.com;
return 301 https://$server_name$request_uri;
}
### Required Changes
1. **Change default passwords**: Update `DB_PASSWORD` and `ADMIN_PASSWORD`
2. **Use HTTPS**: Configure SSL/TLS certificates for production
3. **Secure domains**: Use your own domains, not the examples
4. **Google OAuth**: Create your own OAuth credentials
server {
listen 443 ssl;
server_name your-domain.com;
# SSL configuration
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
### Recommended
- Use strong, unique passwords (20+ characters)
- Enable firewall rules for your server
- Regular security updates for the host system
- Monitor logs for suspicious activity
server {
listen 443 ssl;
server_name api.your-domain.com;
# SSL configuration
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
```
## 🚨 Troubleshooting
### SSL/HTTPS Setup
1. Obtain SSL certificates (Let's Encrypt recommended)
2. Configure your reverse proxy for HTTPS
3. Update your `.env` file with HTTPS URLs
4. Update Google OAuth redirect URIs to use HTTPS
## 🔍 Troubleshooting
### Common Issues
**OAuth Not Working**:
**1. OAuth Login Fails**
- Check Google OAuth configuration
- Verify redirect URIs match exactly
- Ensure HTTPS is used in production
**2. Database Connection Issues**
- Check if PostgreSQL container is healthy: `docker-compose ps`
- Verify database password in `.env`
**3. Frontend Can't Reach Backend**
- Verify `VITE_API_URL` in `.env` matches your backend URL
- Check if backend is accessible: `curl http://localhost:3000/health`
**4. Permission Denied Errors**
- Ensure Docker has proper permissions
- Check file ownership and permissions
### Viewing Logs
```bash
# Check Google OAuth configuration
docker-compose -f docker-compose.prod.yml logs backend | grep -i oauth
# View all logs
docker-compose logs
# Verify redirect URI matches exactly in Google Console
```
# View specific service logs
docker-compose logs backend
docker-compose logs frontend
docker-compose logs db
**Database Connection Error**:
```bash
# Check database status
docker-compose -f docker-compose.prod.yml ps db
# View database logs
docker-compose -f docker-compose.prod.yml logs db
```
**Frontend Can't Connect to Backend**:
```bash
# Verify backend is running
curl http://localhost:3000/api/health
# Check CORS configuration
docker-compose -f docker-compose.prod.yml logs backend | grep -i cors
# Follow logs in real-time
docker-compose logs -f backend
```
### Health Checks
```bash
# Check all service health
docker-compose -f docker-compose.prod.yml ps
# Check container status
docker-compose ps
# Test API health endpoint
curl http://localhost:3000/api/health
# Check backend health
curl http://localhost:3000/health
# Test frontend
# Check frontend
curl http://localhost/
```
## 🔄 Updates
To update to the latest version:
```bash
# Pull latest images
docker-compose pull
# Restart with new images
docker-compose up -d
```
## 🛑 Stopping the Application
```bash
# Stop all services
docker-compose down
# Stop and remove volumes (⚠️ This will delete all data)
docker-compose down -v
```
## 📊 Monitoring
### Container Health
All containers include health checks:
- **Backend**: API endpoint health check
- **Database**: PostgreSQL connection check
- **Redis**: Redis ping check
- **Frontend**: Nginx status check
### Logs
```bash
# View all logs
docker-compose -f docker-compose.prod.yml logs
Logs are automatically rotated and can be viewed using Docker commands.
# Follow specific service logs
docker-compose -f docker-compose.prod.yml logs -f backend
docker-compose -f docker-compose.prod.yml logs -f frontend
docker-compose -f docker-compose.prod.yml logs -f db
```
## 🔐 Security Considerations
## 🔄 Updates and Maintenance
1. **Change default passwords** in `.env`
2. **Use HTTPS** in production
3. **Secure your server** with firewall rules
4. **Regular backups** of database volumes
5. **Keep Docker images updated**
### Updating the Application
## 📞 Support
```bash
# Pull latest changes
git pull origin main
If you encounter issues:
# Rebuild and restart
docker-compose -f docker-compose.prod.yml down
docker-compose -f docker-compose.prod.yml up -d --build
```
1. Check the troubleshooting section above
2. Review container logs
3. Verify your configuration
4. Check GitHub issues for known problems
### Backup Database
## 🎉 Success!
```bash
# Create database backup
docker-compose -f docker-compose.prod.yml exec db pg_dump -U postgres vip_coordinator > backup.sql
Once deployed, you'll have a fully functional VIP Coordinator system with:
- ✅ Google OAuth authentication
- ✅ Mobile-friendly interface
- ✅ Real-time scheduling
- ✅ User management
- ✅ Automatic backups
- ✅ Health monitoring
# Restore from backup
docker-compose -f docker-compose.prod.yml exec -T db psql -U postgres vip_coordinator < backup.sql
```
## 📚 Additional Resources
- **API Documentation**: Available at `/api-docs.html` when running
- **User Roles**: Administrator, Coordinator, Driver
- **Flight Tracking**: Configure AviationStack API key in admin panel
- **Support**: Check GitHub issues for common problems
## 🆘 Getting Help
1. Check this deployment guide
2. Review the troubleshooting section
3. Check Docker container logs
4. Verify environment configuration
5. Test with health check endpoints
---
**VIP Coordinator** - Streamlined VIP logistics management with modern containerized deployment.
The first user to log in will automatically become the system administrator.