# Deployment Guide

## ⚠️ **Production Server Setup Required**

**IMPORTANT**: The automated deployment is currently disabled until your production server is properly configured.

### Current Status:
- ✅ CI/CD Pipeline: Fully configured
- ✅ Code Quality: Automated checks working
- ✅ Docker Images: Building successfully
- ❌ Production Server: **Needs setup** (deployment disabled)

### Required Setup Steps:

1. **Set up your production server** following the detailed guide:
   📖 **[Complete Production Server Setup Guide](docs/production-server-setup.md)**

2. **Enable automatic deployment** once server is ready by editing `.github/workflows/ci-cd.yml`

### Deployment Secrets Configured:
- ✅ `PROD_HOST` - Production server address
- ✅ `PROD_USERNAME` - SSH username (deployment)
- ✅ `PROD_SSH_KEY` - SSH private key for authentication

### Why Deployment is Disabled:

The CI/CD pipeline was failing because:
- `/opt/stiftung` directory doesn't exist on server
- Docker is not installed on production server  
- Git repository not cloned to server
- Environment variables not configured

### Re-enabling Deployment:

After completing the server setup, edit `.github/workflows/ci-cd.yml` and change:

```yaml
if: github.ref == 'refs/heads/main' && false  # Disabled until production server is set up
```

To:
```yaml
if: github.ref == 'refs/heads/main'
```

### Deployment Process:

1. **Automatic Triggers:**
   - Push to `main` branch
   - Manual workflow dispatch from GitHub Actions

2. **Pipeline Steps:**
   - Code quality checks (flake8, black, isort, bandit)
   - Automated testing with PostgreSQL
   - Docker image building
   - Secure deployment to production server
   - Health checks and verification

3. **Deployment Files:**
   - `deploy-production/` - Ubuntu/Debian production setup
   - `deploy-synology/` - Synology NAS deployment option

### Manual Deployment:

If you need to deploy manually:

```bash
# 1. Prepare production server
sudo bash deploy-production/server-setup.sh

# 2. Deploy application
bash deploy-production/deploy.sh
```

### Monitoring:

- GitHub Actions: Monitor deployment status
- Server logs: `docker-compose logs -f`
- Application health: Check configured health endpoints

### Next Steps:

1. Monitor the first automated deployment
2. Configure SSL certificates with Certbot
3. Set up monitoring and backups
4. Configure domain DNS

---
*Last updated: September 6, 2025*
*Pipeline configured for user: deployment*
