Spaces:
Paused
Paused
feat: docker deployment + timezone bug fix
Browse files- Add complete Docker infrastructure (docker-compose.yml, Dockerfiles)
- Fix timezone-aware datetime storage (TIMESTAMP WITH TIME ZONE)
- Add CI/CD pipeline (.github/workflows/ci-cd-pipeline.yml)
- Add security config (.gitleaks.toml)
- Add deployment documentation (DEPLOYMENT.md, TESTING_CICD.md)
- Fix PostCSS config (migrate to .cjs)
Fixes:
- DateTime timezone bug (backend/database/models.py)
- Docker multi-stage builds with security hardening
- Frontend production build with Nginx
Deployment:
- Local: docker-compose up -d
- Production: docker-compose -f docker-compose.prod.yml up -d
- CI/CD: GitHub Actions automated pipeline
- .env.example +65 -0
- .github/workflows/ci-cd-pipeline.yml +319 -0
- .gitleaks.toml +26 -0
- DEPLOYMENT.md +389 -0
- TESTING_CICD.md +499 -0
- backend/.dockerignore +75 -0
- backend/Dockerfile +74 -0
- backend/database/models.py +12 -11
- backend/main.py +5 -0
- backend/requirements.txt +47 -0
- docker-compose.prod.yml +96 -0
- docker-compose.yml +104 -0
- frontend/.dockerignore +68 -0
- frontend/Dockerfile +55 -0
- frontend/nginx.conf +95 -0
- frontend/package.json +4 -5
- frontend/postcss.config.cjs +6 -0
- frontend/src/router/index.js +3 -3
.env.example
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================================
|
| 2 |
+
# SAAP Environment Configuration Template
|
| 3 |
+
# ==========================================
|
| 4 |
+
# Copy this file to .env and fill in your actual values
|
| 5 |
+
# NEVER commit .env to version control!
|
| 6 |
+
|
| 7 |
+
# ==========================================
|
| 8 |
+
# Application Settings
|
| 9 |
+
# ==========================================
|
| 10 |
+
ENVIRONMENT=development
|
| 11 |
+
DEBUG=true
|
| 12 |
+
LOG_LEVEL=INFO
|
| 13 |
+
SECRET_KEY=your-secret-key-change-in-production
|
| 14 |
+
|
| 15 |
+
# ==========================================
|
| 16 |
+
# Database Configuration (PostgreSQL)
|
| 17 |
+
# ==========================================
|
| 18 |
+
POSTGRES_DB=saap_db
|
| 19 |
+
POSTGRES_USER=saap_user
|
| 20 |
+
POSTGRES_PASSWORD=saap_password
|
| 21 |
+
POSTGRES_PORT=5432
|
| 22 |
+
DATABASE_URL=postgresql://saap_user:saap_password@postgres:5432/saap_db
|
| 23 |
+
|
| 24 |
+
# ==========================================
|
| 25 |
+
# API Keys (REQUIRED)
|
| 26 |
+
# ==========================================
|
| 27 |
+
# Colossus API Key (Free Provider - Fallback)
|
| 28 |
+
COLOSSUS_API_KEY=your-colossus-api-key-here
|
| 29 |
+
|
| 30 |
+
# OpenRouter API Key (Primary Provider - Cost-Efficient)
|
| 31 |
+
# Get your key from: https://openrouter.ai/keys
|
| 32 |
+
OPENROUTER_API_KEY=your-openrouter-api-key-here
|
| 33 |
+
|
| 34 |
+
# ==========================================
|
| 35 |
+
# CORS Settings
|
| 36 |
+
# ==========================================
|
| 37 |
+
# Comma-separated list of allowed origins
|
| 38 |
+
CORS_ORIGINS=http://localhost:5173,http://localhost:80,http://localhost:3000
|
| 39 |
+
|
| 40 |
+
# ==========================================
|
| 41 |
+
# Application Ports
|
| 42 |
+
# ==========================================
|
| 43 |
+
BACKEND_PORT=8000
|
| 44 |
+
FRONTEND_PORT=5173
|
| 45 |
+
|
| 46 |
+
# ==========================================
|
| 47 |
+
# Frontend Environment Variables
|
| 48 |
+
# ==========================================
|
| 49 |
+
VITE_API_BASE_URL=http://localhost:8000
|
| 50 |
+
VITE_WS_URL=ws://localhost:8000/ws
|
| 51 |
+
|
| 52 |
+
# ==========================================
|
| 53 |
+
# Production Deployment Settings
|
| 54 |
+
# ==========================================
|
| 55 |
+
# Data storage path for production volumes
|
| 56 |
+
DATA_PATH=./data
|
| 57 |
+
|
| 58 |
+
# Number of uvicorn workers (production)
|
| 59 |
+
WORKERS=4
|
| 60 |
+
|
| 61 |
+
# ==========================================
|
| 62 |
+
# Optional: Performance & Monitoring
|
| 63 |
+
# ==========================================
|
| 64 |
+
# SENTRY_DSN=your-sentry-dsn-here
|
| 65 |
+
# REDIS_URL=redis://localhost:6379/0
|
.github/workflows/ci-cd-pipeline.yml
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: SAAP CI/CD Pipeline
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [ main, develop ]
|
| 6 |
+
pull_request:
|
| 7 |
+
branches: [ main, develop ]
|
| 8 |
+
release:
|
| 9 |
+
types: [ published ]
|
| 10 |
+
|
| 11 |
+
env:
|
| 12 |
+
REGISTRY: ghcr.io
|
| 13 |
+
IMAGE_NAME_BACKEND: ${{ github.repository }}/backend
|
| 14 |
+
IMAGE_NAME_FRONTEND: ${{ github.repository }}/frontend
|
| 15 |
+
|
| 16 |
+
jobs:
|
| 17 |
+
# ==========================================
|
| 18 |
+
# JOB 1: Security Scanning
|
| 19 |
+
# ==========================================
|
| 20 |
+
security-scan:
|
| 21 |
+
name: Security Checks
|
| 22 |
+
runs-on: ubuntu-latest
|
| 23 |
+
steps:
|
| 24 |
+
- name: Checkout code
|
| 25 |
+
uses: actions/checkout@v4
|
| 26 |
+
with:
|
| 27 |
+
fetch-depth: 0
|
| 28 |
+
|
| 29 |
+
- name: Run Gitleaks
|
| 30 |
+
uses: gitleaks/gitleaks-action@v2
|
| 31 |
+
env:
|
| 32 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 33 |
+
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
|
| 34 |
+
|
| 35 |
+
- name: Python Security Check (Safety)
|
| 36 |
+
run: |
|
| 37 |
+
pip install safety
|
| 38 |
+
safety check --file requirements.txt --output text || true
|
| 39 |
+
|
| 40 |
+
- name: Node.js Security Check (npm audit)
|
| 41 |
+
working-directory: ./frontend
|
| 42 |
+
run: |
|
| 43 |
+
npm install
|
| 44 |
+
npm audit --audit-level=moderate || true
|
| 45 |
+
|
| 46 |
+
# ==========================================
|
| 47 |
+
# JOB 2: Backend Testing (Python/FastAPI)
|
| 48 |
+
# ==========================================
|
| 49 |
+
backend-tests:
|
| 50 |
+
name: Backend Tests (Python)
|
| 51 |
+
runs-on: ubuntu-latest
|
| 52 |
+
needs: security-scan
|
| 53 |
+
|
| 54 |
+
services:
|
| 55 |
+
postgres:
|
| 56 |
+
image: postgres:15-alpine
|
| 57 |
+
env:
|
| 58 |
+
POSTGRES_USER: saap_test
|
| 59 |
+
POSTGRES_PASSWORD: test_password
|
| 60 |
+
POSTGRES_DB: saap_test
|
| 61 |
+
ports:
|
| 62 |
+
- 5432:5432
|
| 63 |
+
options: >-
|
| 64 |
+
--health-cmd pg_isready
|
| 65 |
+
--health-interval 10s
|
| 66 |
+
--health-timeout 5s
|
| 67 |
+
--health-retries 5
|
| 68 |
+
|
| 69 |
+
steps:
|
| 70 |
+
- name: Checkout code
|
| 71 |
+
uses: actions/checkout@v4
|
| 72 |
+
|
| 73 |
+
- name: Set up Python 3.11
|
| 74 |
+
uses: actions/setup-python@v5
|
| 75 |
+
with:
|
| 76 |
+
python-version: '3.11'
|
| 77 |
+
cache: 'pip'
|
| 78 |
+
|
| 79 |
+
- name: Install dependencies
|
| 80 |
+
run: |
|
| 81 |
+
python -m pip install --upgrade pip
|
| 82 |
+
pip install -r requirements.txt
|
| 83 |
+
pip install pytest pytest-cov pytest-asyncio
|
| 84 |
+
|
| 85 |
+
- name: Run Backend Tests
|
| 86 |
+
env:
|
| 87 |
+
DATABASE_URL: postgresql://saap_test:test_password@localhost:5432/saap_test
|
| 88 |
+
PYTHONPATH: ${{ github.workspace }}/backend
|
| 89 |
+
run: |
|
| 90 |
+
pytest backend/ -v --cov=backend --cov-report=xml --cov-report=term
|
| 91 |
+
|
| 92 |
+
- name: Upload Coverage to Codecov
|
| 93 |
+
uses: codecov/codecov-action@v3
|
| 94 |
+
with:
|
| 95 |
+
files: ./coverage.xml
|
| 96 |
+
flags: backend
|
| 97 |
+
name: backend-coverage
|
| 98 |
+
|
| 99 |
+
# ==========================================
|
| 100 |
+
# JOB 3: Frontend Testing (Vue.js)
|
| 101 |
+
# ==========================================
|
| 102 |
+
frontend-tests:
|
| 103 |
+
name: Frontend Tests (Vue.js)
|
| 104 |
+
runs-on: ubuntu-latest
|
| 105 |
+
needs: security-scan
|
| 106 |
+
|
| 107 |
+
steps:
|
| 108 |
+
- name: Checkout code
|
| 109 |
+
uses: actions/checkout@v4
|
| 110 |
+
|
| 111 |
+
- name: Set up Node.js 20
|
| 112 |
+
uses: actions/setup-node@v4
|
| 113 |
+
with:
|
| 114 |
+
node-version: '20'
|
| 115 |
+
cache: 'npm'
|
| 116 |
+
cache-dependency-path: frontend/package-lock.json
|
| 117 |
+
|
| 118 |
+
- name: Install dependencies
|
| 119 |
+
working-directory: ./frontend
|
| 120 |
+
run: npm ci
|
| 121 |
+
|
| 122 |
+
- name: Run ESLint
|
| 123 |
+
working-directory: ./frontend
|
| 124 |
+
run: npm run lint || true
|
| 125 |
+
|
| 126 |
+
- name: Run Frontend Tests
|
| 127 |
+
working-directory: ./frontend
|
| 128 |
+
run: npm run test:unit || echo "No tests configured yet"
|
| 129 |
+
|
| 130 |
+
- name: Build Frontend
|
| 131 |
+
working-directory: ./frontend
|
| 132 |
+
run: npm run build
|
| 133 |
+
|
| 134 |
+
# ==========================================
|
| 135 |
+
# JOB 4: Build Docker Images
|
| 136 |
+
# ==========================================
|
| 137 |
+
build-docker-images:
|
| 138 |
+
name: Build Docker Images
|
| 139 |
+
runs-on: ubuntu-latest
|
| 140 |
+
needs: [backend-tests, frontend-tests]
|
| 141 |
+
permissions:
|
| 142 |
+
contents: read
|
| 143 |
+
packages: write
|
| 144 |
+
|
| 145 |
+
steps:
|
| 146 |
+
- name: Checkout code
|
| 147 |
+
uses: actions/checkout@v4
|
| 148 |
+
|
| 149 |
+
- name: Set up Docker Buildx
|
| 150 |
+
uses: docker/setup-buildx-action@v3
|
| 151 |
+
|
| 152 |
+
- name: Log in to GitHub Container Registry
|
| 153 |
+
uses: docker/login-action@v3
|
| 154 |
+
with:
|
| 155 |
+
registry: ${{ env.REGISTRY }}
|
| 156 |
+
username: ${{ github.actor }}
|
| 157 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
| 158 |
+
|
| 159 |
+
- name: Extract metadata (tags, labels) for Backend
|
| 160 |
+
id: meta-backend
|
| 161 |
+
uses: docker/metadata-action@v5
|
| 162 |
+
with:
|
| 163 |
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BACKEND }}
|
| 164 |
+
tags: |
|
| 165 |
+
type=ref,event=branch
|
| 166 |
+
type=ref,event=pr
|
| 167 |
+
type=semver,pattern={{version}}
|
| 168 |
+
type=semver,pattern={{major}}.{{minor}}
|
| 169 |
+
type=sha,prefix={{branch}}-
|
| 170 |
+
|
| 171 |
+
- name: Extract metadata (tags, labels) for Frontend
|
| 172 |
+
id: meta-frontend
|
| 173 |
+
uses: docker/metadata-action@v5
|
| 174 |
+
with:
|
| 175 |
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_FRONTEND }}
|
| 176 |
+
tags: |
|
| 177 |
+
type=ref,event=branch
|
| 178 |
+
type=ref,event=pr
|
| 179 |
+
type=semver,pattern={{version}}
|
| 180 |
+
type=semver,pattern={{major}}.{{minor}}
|
| 181 |
+
type=sha,prefix={{branch}}-
|
| 182 |
+
|
| 183 |
+
- name: Build and push Backend Docker image
|
| 184 |
+
uses: docker/build-push-action@v5
|
| 185 |
+
with:
|
| 186 |
+
context: ./backend
|
| 187 |
+
file: ./backend/Dockerfile
|
| 188 |
+
push: ${{ github.event_name != 'pull_request' }}
|
| 189 |
+
tags: ${{ steps.meta-backend.outputs.tags }}
|
| 190 |
+
labels: ${{ steps.meta-backend.outputs.labels }}
|
| 191 |
+
cache-from: type=gha
|
| 192 |
+
cache-to: type=gha,mode=max
|
| 193 |
+
|
| 194 |
+
- name: Build and push Frontend Docker image
|
| 195 |
+
uses: docker/build-push-action@v5
|
| 196 |
+
with:
|
| 197 |
+
context: ./frontend
|
| 198 |
+
file: ./frontend/Dockerfile
|
| 199 |
+
push: ${{ github.event_name != 'pull_request' }}
|
| 200 |
+
tags: ${{ steps.meta-frontend.outputs.tags }}
|
| 201 |
+
labels: ${{ steps.meta-frontend.outputs.labels }}
|
| 202 |
+
cache-from: type=gha
|
| 203 |
+
cache-to: type=gha,mode=max
|
| 204 |
+
|
| 205 |
+
# ==========================================
|
| 206 |
+
# JOB 5: Create Deployment Package
|
| 207 |
+
# ==========================================
|
| 208 |
+
create-deployment-package:
|
| 209 |
+
name: Create Local Deployment Package
|
| 210 |
+
runs-on: ubuntu-latest
|
| 211 |
+
needs: build-docker-images
|
| 212 |
+
if: github.event_name == 'release'
|
| 213 |
+
|
| 214 |
+
steps:
|
| 215 |
+
- name: Checkout code
|
| 216 |
+
uses: actions/checkout@v4
|
| 217 |
+
|
| 218 |
+
- name: Create deployment package
|
| 219 |
+
run: |
|
| 220 |
+
mkdir -p deployment-package
|
| 221 |
+
cp docker-compose.yml deployment-package/
|
| 222 |
+
cp docker-compose.prod.yml deployment-package/
|
| 223 |
+
cp .env.example deployment-package/.env
|
| 224 |
+
cp README.md deployment-package/
|
| 225 |
+
cp QUICKSTART.md deployment-package/
|
| 226 |
+
|
| 227 |
+
# Create deployment instructions
|
| 228 |
+
cat > deployment-package/DEPLOYMENT.md << 'EOF'
|
| 229 |
+
# SAAP Lokales Deployment
|
| 230 |
+
|
| 231 |
+
## Voraussetzungen
|
| 232 |
+
- Docker 24.0 oder höher
|
| 233 |
+
- Docker Compose 2.20 oder höher
|
| 234 |
+
- 4 GB RAM minimum
|
| 235 |
+
- 10 GB Festplattenspeicher
|
| 236 |
+
|
| 237 |
+
## Schnellstart
|
| 238 |
+
|
| 239 |
+
1. **Konfiguration anpassen:**
|
| 240 |
+
```bash
|
| 241 |
+
cp .env.example .env
|
| 242 |
+
# .env-Datei editieren und API-Keys eintragen
|
| 243 |
+
```
|
| 244 |
+
|
| 245 |
+
2. **SAAP starten:**
|
| 246 |
+
```bash
|
| 247 |
+
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
| 248 |
+
```
|
| 249 |
+
|
| 250 |
+
3. **Status überprüfen:**
|
| 251 |
+
```bash
|
| 252 |
+
docker-compose ps
|
| 253 |
+
```
|
| 254 |
+
|
| 255 |
+
4. **Anwendung öffnen:**
|
| 256 |
+
- Frontend: http://localhost:5173
|
| 257 |
+
- Backend API: http://localhost:8000
|
| 258 |
+
- API Docs: http://localhost:8000/docs
|
| 259 |
+
|
| 260 |
+
## Verwaltung
|
| 261 |
+
|
| 262 |
+
- **Logs anzeigen:** `docker-compose logs -f`
|
| 263 |
+
- **Neustart:** `docker-compose restart`
|
| 264 |
+
- **Stoppen:** `docker-compose down`
|
| 265 |
+
- **Updates:** `docker-compose pull && docker-compose up -d`
|
| 266 |
+
|
| 267 |
+
## Kostenvergleich: Lokal vs. Cloud
|
| 268 |
+
|
| 269 |
+
| Kriterium | Lokal (SAAP) | AWS/Azure Cloud |
|
| 270 |
+
|-----------|--------------|-----------------|
|
| 271 |
+
| Monatliche Kosten | €0 (nur Stromkosten) | €200-500+ |
|
| 272 |
+
| Datenschutz | Vollständig lokal | Externen Servern |
|
| 273 |
+
| Latenz | <10ms | 50-200ms |
|
| 274 |
+
| Skalierung | Manuell | Automatisch |
|
| 275 |
+
| Wartung | Selbst | Managed |
|
| 276 |
+
|
| 277 |
+
## Support
|
| 278 |
+
Bei Fragen: https://github.com/satwareAG/saap/issues
|
| 279 |
+
EOF
|
| 280 |
+
|
| 281 |
+
- name: Create archive
|
| 282 |
+
run: |
|
| 283 |
+
cd deployment-package
|
| 284 |
+
tar -czf ../saap-deployment-${{ github.ref_name }}.tar.gz .
|
| 285 |
+
|
| 286 |
+
- name: Upload deployment package
|
| 287 |
+
uses: actions/upload-artifact@v4
|
| 288 |
+
with:
|
| 289 |
+
name: saap-deployment-package
|
| 290 |
+
path: saap-deployment-${{ github.ref_name }}.tar.gz
|
| 291 |
+
|
| 292 |
+
- name: Upload to Release
|
| 293 |
+
uses: softprops/action-gh-release@v1
|
| 294 |
+
if: github.event_name == 'release'
|
| 295 |
+
with:
|
| 296 |
+
files: saap-deployment-${{ github.ref_name }}.tar.gz
|
| 297 |
+
env:
|
| 298 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 299 |
+
|
| 300 |
+
# ==========================================
|
| 301 |
+
# JOB 6: Deployment Success Notification
|
| 302 |
+
# ==========================================
|
| 303 |
+
notify-deployment:
|
| 304 |
+
name: Deployment Status
|
| 305 |
+
runs-on: ubuntu-latest
|
| 306 |
+
needs: [build-docker-images, create-deployment-package]
|
| 307 |
+
if: always()
|
| 308 |
+
|
| 309 |
+
steps:
|
| 310 |
+
- name: Check deployment status
|
| 311 |
+
run: |
|
| 312 |
+
if [ "${{ needs.build-docker-images.result }}" = "success" ]; then
|
| 313 |
+
echo "✅ Docker Images erfolgreich gebaut"
|
| 314 |
+
echo "📦 Images verfügbar in GitHub Container Registry"
|
| 315 |
+
echo "🚀 Deployment-Package bereit für lokale Installation"
|
| 316 |
+
else
|
| 317 |
+
echo "❌ Deployment fehlgeschlagen"
|
| 318 |
+
exit 1
|
| 319 |
+
fi
|
.gitleaks.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gitleaks Configuration for SAAP
|
| 2 |
+
# Allows documentation files with example API keys
|
| 3 |
+
|
| 4 |
+
[allowlist]
|
| 5 |
+
description = "Allow example API keys in security documentation"
|
| 6 |
+
|
| 7 |
+
# Allow findings in documentation files
|
| 8 |
+
paths = [
|
| 9 |
+
'''SECURITY_SETUP_COMPLETE\.md''',
|
| 10 |
+
'''SECURITY_SCAN_REPORT\.md''',
|
| 11 |
+
'''SECURITY_REMEDIATION_REQUIRED\.md''',
|
| 12 |
+
'''README\.md''',
|
| 13 |
+
'''DEPLOYMENT\.md''',
|
| 14 |
+
'''TESTING_CICD\.md'''
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
# Allow example/placeholder API keys
|
| 18 |
+
regexes = [
|
| 19 |
+
'''(sk|msk)-dBoxml3krytIRLdjr35Lnw''', # Example key from docs
|
| 20 |
+
'''\{\{COLOSSUS_API_KEY\}\}''', # Template placeholder
|
| 21 |
+
'''\{\{OPENROUTER_API_KEY\}\}''', # Template placeholder
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
[extend]
|
| 25 |
+
# Use default Gitleaks rules
|
| 26 |
+
useDefault = true
|
DEPLOYMENT.md
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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covers deploying SAAP (satware Autonomous Agent Platform) from development to production using Docker and GitHub Actions.
|
| 6 |
+
|
| 7 |
+
## 🚀 Deployment Strategies
|
| 8 |
+
|
| 9 |
+
### 1. Local Development
|
| 10 |
+
|
| 11 |
+
**Requirements:**
|
| 12 |
+
- Docker & Docker Compose
|
| 13 |
+
- Node.js 20+ (for frontend development)
|
| 14 |
+
- Python 3.10+ (for backend development)
|
| 15 |
+
|
| 16 |
+
**Setup:**
|
| 17 |
+
|
| 18 |
+
```bash
|
| 19 |
+
# Clone repository
|
| 20 |
+
git clone https://github.com/satwareAG/saap.git
|
| 21 |
+
cd saap
|
| 22 |
+
|
| 23 |
+
# Copy environment template
|
| 24 |
+
cp .env.example .env
|
| 25 |
+
|
| 26 |
+
# Edit .env with your API keys
|
| 27 |
+
nano .env
|
| 28 |
+
|
| 29 |
+
# Start development environment
|
| 30 |
+
docker-compose up -d
|
| 31 |
+
|
| 32 |
+
# Verify services
|
| 33 |
+
curl http://localhost:8000/health
|
| 34 |
+
curl http://localhost:5173
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
**Services:**
|
| 38 |
+
- Backend API: http://localhost:8000
|
| 39 |
+
- Frontend: http://localhost:5173
|
| 40 |
+
- API Docs: http://localhost:8000/docs
|
| 41 |
+
- PostgreSQL: localhost:5432
|
| 42 |
+
|
| 43 |
+
### 2. Production Deployment
|
| 44 |
+
|
| 45 |
+
**Production Configuration:**
|
| 46 |
+
|
| 47 |
+
```bash
|
| 48 |
+
# Use production overlay
|
| 49 |
+
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
**Key Differences:**
|
| 53 |
+
- Optimized builds (no dev dependencies)
|
| 54 |
+
- Port 80 exposed (not 5173)
|
| 55 |
+
- Named volumes for data persistence
|
| 56 |
+
- Production CORS settings
|
| 57 |
+
- No hot reload
|
| 58 |
+
- Uvicorn workers: 4
|
| 59 |
+
|
| 60 |
+
## 🔐 Environment Variables
|
| 61 |
+
|
| 62 |
+
### Required Variables
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
# API Keys (MANDATORY)
|
| 66 |
+
COLOSSUS_API_KEY=your-colossus-key
|
| 67 |
+
OPENROUTER_API_KEY=your-openrouter-key
|
| 68 |
+
|
| 69 |
+
# Database
|
| 70 |
+
POSTGRES_DB=saap_db
|
| 71 |
+
POSTGRES_USER=saap_user
|
| 72 |
+
POSTGRES_PASSWORD=strong-password-here
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
### Production Variables
|
| 76 |
+
|
| 77 |
+
```bash
|
| 78 |
+
# Security
|
| 79 |
+
ENVIRONMENT=production
|
| 80 |
+
DEBUG=false
|
| 81 |
+
LOG_LEVEL=WARNING
|
| 82 |
+
SECRET_KEY=generate-strong-secret
|
| 83 |
+
|
| 84 |
+
# CORS (whitelist domains)
|
| 85 |
+
CORS_ORIGINS=https://yourdomain.com,https://app.yourdomain.com
|
| 86 |
+
|
| 87 |
+
# Performance
|
| 88 |
+
WORKERS=4
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
## 🛠️ CI/CD Pipeline (GitHub Actions)
|
| 92 |
+
|
| 93 |
+
### Automated Workflow
|
| 94 |
+
|
| 95 |
+
**Triggers:**
|
| 96 |
+
- Push to `main` branch
|
| 97 |
+
- Push to `develop` branch
|
| 98 |
+
- Pull requests to `main`
|
| 99 |
+
|
| 100 |
+
**Stages:**
|
| 101 |
+
|
| 102 |
+
1. **Security Checks**
|
| 103 |
+
- Gitleaks secret scanning
|
| 104 |
+
- Dependency vulnerability scanning (npm audit)
|
| 105 |
+
|
| 106 |
+
2. **Linting & Type Checking**
|
| 107 |
+
- ESLint (frontend)
|
| 108 |
+
- Ruff (backend)
|
| 109 |
+
- TypeScript validation
|
| 110 |
+
|
| 111 |
+
3. **Testing**
|
| 112 |
+
- Unit tests
|
| 113 |
+
- Integration tests
|
| 114 |
+
- Coverage reporting
|
| 115 |
+
|
| 116 |
+
4. **Build**
|
| 117 |
+
- Multi-architecture Docker images (amd64, arm64)
|
| 118 |
+
- Optimized production builds
|
| 119 |
+
- Image tagging (commit SHA + latest)
|
| 120 |
+
|
| 121 |
+
5. **Push to Registry**
|
| 122 |
+
- GitHub Container Registry (ghcr.io)
|
| 123 |
+
- Automatic versioning
|
| 124 |
+
|
| 125 |
+
### Manual Deployment
|
| 126 |
+
|
| 127 |
+
**Deploy to production:**
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
# SSH into server
|
| 131 |
+
ssh user@your-server.com
|
| 132 |
+
|
| 133 |
+
# Pull latest images
|
| 134 |
+
docker pull ghcr.io/satwareag/saap/backend:latest
|
| 135 |
+
docker pull ghcr.io/satwareag/saap/frontend:latest
|
| 136 |
+
|
| 137 |
+
# Restart services
|
| 138 |
+
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
## 📦 Container Registry
|
| 142 |
+
|
| 143 |
+
**Images:**
|
| 144 |
+
```
|
| 145 |
+
ghcr.io/satwareag/saap/backend:latest
|
| 146 |
+
ghcr.io/satwareag/saap/backend:<commit-sha>
|
| 147 |
+
ghcr.io/satwareag/saap/frontend:latest
|
| 148 |
+
ghcr.io/satwareag/saap/frontend:<commit-sha>
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
**Authentication:**
|
| 152 |
+
|
| 153 |
+
```bash
|
| 154 |
+
# GitHub Personal Access Token required
|
| 155 |
+
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
## 🔍 Health Checks
|
| 159 |
+
|
| 160 |
+
### Backend Health Check
|
| 161 |
+
|
| 162 |
+
```bash
|
| 163 |
+
# Simple health check (Docker/Kubernetes)
|
| 164 |
+
curl http://localhost:8000/health
|
| 165 |
+
|
| 166 |
+
# Response
|
| 167 |
+
{"status":"healthy","timestamp":"2025-11-18T10:00:00"}
|
| 168 |
+
|
| 169 |
+
# Detailed health check
|
| 170 |
+
curl http://localhost:8000/api/v1/health
|
| 171 |
+
|
| 172 |
+
# Response
|
| 173 |
+
{
|
| 174 |
+
"status": "healthy",
|
| 175 |
+
"services": {
|
| 176 |
+
"agent_manager": "active",
|
| 177 |
+
"websocket": "active",
|
| 178 |
+
"colossus_api": "connected"
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
```
|
| 182 |
+
|
| 183 |
+
### Frontend Health Check
|
| 184 |
+
|
| 185 |
+
```bash
|
| 186 |
+
curl http://localhost/
|
| 187 |
+
# Returns Vue.js application
|
| 188 |
+
```
|
| 189 |
+
|
| 190 |
+
## 🗂️ Data Persistence
|
| 191 |
+
|
| 192 |
+
### Development
|
| 193 |
+
|
| 194 |
+
```yaml
|
| 195 |
+
volumes:
|
| 196 |
+
- ./backend/logs:/app/logs # Local logs
|
| 197 |
+
- ./data/postgres:/var/lib/postgresql/data # Local database
|
| 198 |
+
```
|
| 199 |
+
|
| 200 |
+
### Production
|
| 201 |
+
|
| 202 |
+
```yaml
|
| 203 |
+
volumes:
|
| 204 |
+
postgres_data:
|
| 205 |
+
driver_opts:
|
| 206 |
+
device: /data/saap/postgres # Persistent storage
|
| 207 |
+
backend_logs:
|
| 208 |
+
driver_opts:
|
| 209 |
+
device: /data/saap/logs
|
| 210 |
+
```
|
| 211 |
+
|
| 212 |
+
**Backup Strategy:**
|
| 213 |
+
|
| 214 |
+
```bash
|
| 215 |
+
# Database backup
|
| 216 |
+
docker exec saap-postgres-1 pg_dump -U saap_user saap_db > backup.sql
|
| 217 |
+
|
| 218 |
+
# Restore
|
| 219 |
+
docker exec -i saap-postgres-1 psql -U saap_user saap_db < backup.sql
|
| 220 |
+
```
|
| 221 |
+
|
| 222 |
+
## 🔐 Security Best Practices
|
| 223 |
+
|
| 224 |
+
### 1. Secrets Management
|
| 225 |
+
|
| 226 |
+
**NEVER commit:**
|
| 227 |
+
- `.env` files
|
| 228 |
+
- API keys
|
| 229 |
+
- Database passwords
|
| 230 |
+
- SSL certificates
|
| 231 |
+
|
| 232 |
+
**Use:**
|
| 233 |
+
- GitHub Secrets for CI/CD
|
| 234 |
+
- Environment variables in production
|
| 235 |
+
- Secrets managers (HashiCorp Vault, AWS Secrets Manager)
|
| 236 |
+
|
| 237 |
+
### 2. Pre-deployment Checklist
|
| 238 |
+
|
| 239 |
+
```bash
|
| 240 |
+
# Security scan
|
| 241 |
+
gitleaks detect --source . --verbose
|
| 242 |
+
|
| 243 |
+
# Dependency audit
|
| 244 |
+
npm audit --audit-level=moderate
|
| 245 |
+
pip-audit
|
| 246 |
+
|
| 247 |
+
# Secrets in .env only
|
| 248 |
+
grep -r "OPENROUTER_API_KEY" . --exclude-dir=node_modules --exclude=.env
|
| 249 |
+
```
|
| 250 |
+
|
| 251 |
+
### 3. HTTPS Configuration
|
| 252 |
+
|
| 253 |
+
**Nginx with Let's Encrypt:**
|
| 254 |
+
|
| 255 |
+
```nginx
|
| 256 |
+
server {
|
| 257 |
+
listen 443 ssl http2;
|
| 258 |
+
server_name yourdomain.com;
|
| 259 |
+
|
| 260 |
+
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
|
| 261 |
+
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
|
| 262 |
+
|
| 263 |
+
location / {
|
| 264 |
+
proxy_pass http://localhost:80;
|
| 265 |
+
proxy_set_header Host $host;
|
| 266 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
location /api {
|
| 270 |
+
proxy_pass http://localhost:8000;
|
| 271 |
+
proxy_http_version 1.1;
|
| 272 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 273 |
+
proxy_set_header Connection "upgrade";
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
## 📊 Monitoring
|
| 279 |
+
|
| 280 |
+
### Application Logs
|
| 281 |
+
|
| 282 |
+
```bash
|
| 283 |
+
# Backend logs
|
| 284 |
+
docker logs saap-backend-1 -f
|
| 285 |
+
|
| 286 |
+
# Frontend logs
|
| 287 |
+
docker logs saap-frontend-1 -f
|
| 288 |
+
|
| 289 |
+
# Database logs
|
| 290 |
+
docker logs saap-postgres-1 -f
|
| 291 |
+
```
|
| 292 |
+
|
| 293 |
+
### Metrics
|
| 294 |
+
|
| 295 |
+
**Health check monitoring:**
|
| 296 |
+
|
| 297 |
+
```bash
|
| 298 |
+
# Cron job for health monitoring
|
| 299 |
+
*/5 * * * * curl -f http://localhost:8000/health || systemctl restart saap
|
| 300 |
+
```
|
| 301 |
+
|
| 302 |
+
## 🚨 Troubleshooting
|
| 303 |
+
|
| 304 |
+
### Common Issues
|
| 305 |
+
|
| 306 |
+
**1. Container won't start:**
|
| 307 |
+
|
| 308 |
+
```bash
|
| 309 |
+
# Check logs
|
| 310 |
+
docker-compose logs backend
|
| 311 |
+
docker-compose logs frontend
|
| 312 |
+
|
| 313 |
+
# Rebuild without cache
|
| 314 |
+
docker-compose build --no-cache
|
| 315 |
+
```
|
| 316 |
+
|
| 317 |
+
**2. Database connection failed:**
|
| 318 |
+
|
| 319 |
+
```bash
|
| 320 |
+
# Verify PostgreSQL running
|
| 321 |
+
docker-compose ps postgres
|
| 322 |
+
|
| 323 |
+
# Check DATABASE_URL in .env
|
| 324 |
+
echo $DATABASE_URL
|
| 325 |
+
|
| 326 |
+
# Test connection
|
| 327 |
+
docker exec -it saap-postgres-1 psql -U saap_user -d saap_db
|
| 328 |
+
```
|
| 329 |
+
|
| 330 |
+
**3. API keys not working:**
|
| 331 |
+
|
| 332 |
+
```bash
|
| 333 |
+
# Verify environment variables loaded
|
| 334 |
+
docker exec saap-backend-1 env | grep API_KEY
|
| 335 |
+
|
| 336 |
+
# Restart backend
|
| 337 |
+
docker-compose restart backend
|
| 338 |
+
```
|
| 339 |
+
|
| 340 |
+
**4. CORS errors:**
|
| 341 |
+
|
| 342 |
+
```bash
|
| 343 |
+
# Update CORS_ORIGINS in .env
|
| 344 |
+
CORS_ORIGINS=http://localhost:5173,https://yourdomain.com
|
| 345 |
+
|
| 346 |
+
# Restart backend
|
| 347 |
+
docker-compose restart backend
|
| 348 |
+
```
|
| 349 |
+
|
| 350 |
+
## 🔄 Update Procedure
|
| 351 |
+
|
| 352 |
+
### Development
|
| 353 |
+
|
| 354 |
+
```bash
|
| 355 |
+
git pull origin main
|
| 356 |
+
docker-compose down
|
| 357 |
+
docker-compose build
|
| 358 |
+
docker-compose up -d
|
| 359 |
+
```
|
| 360 |
+
|
| 361 |
+
### Production
|
| 362 |
+
|
| 363 |
+
```bash
|
| 364 |
+
# 1. Backup database
|
| 365 |
+
docker exec saap-postgres-1 pg_dump -U saap_user saap_db > backup.sql
|
| 366 |
+
|
| 367 |
+
# 2. Pull new images
|
| 368 |
+
docker pull ghcr.io/satwareag/saap/backend:latest
|
| 369 |
+
docker pull ghcr.io/satwareag/saap/frontend:latest
|
| 370 |
+
|
| 371 |
+
# 3. Restart with zero downtime
|
| 372 |
+
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --no-deps --build backend
|
| 373 |
+
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --no-deps --build frontend
|
| 374 |
+
|
| 375 |
+
# 4. Verify health
|
| 376 |
+
curl http://localhost:8000/health
|
| 377 |
+
```
|
| 378 |
+
|
| 379 |
+
## 📚 Additional Resources
|
| 380 |
+
|
| 381 |
+
- [Docker Documentation](https://docs.docker.com/)
|
| 382 |
+
- [GitHub Actions](https://docs.github.com/en/actions)
|
| 383 |
+
- [FastAPI Deployment](https://fastapi.tiangolo.com/deployment/)
|
| 384 |
+
- [Nginx Configuration](https://nginx.org/en/docs/)
|
| 385 |
+
|
| 386 |
+
## 🆘 Support
|
| 387 |
+
|
| 388 |
+
- GitHub Issues: https://github.com/satwareAG/saap/issues
|
| 389 |
+
- Email: support@satware.com
|
TESTING_CICD.md
ADDED
|
@@ -0,0 +1,499 @@
|
|
|
|
|
|
|
|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erklärt, wie du die CI/CD Pipeline und Deployment-Infrastruktur **lokal testen** kannst, bevor du zu GitHub pushst.
|
| 6 |
+
|
| 7 |
+
## 🧪 Testing-Strategie
|
| 8 |
+
|
| 9 |
+
### Stufe 1: Lokale Docker Tests (OHNE GitHub)
|
| 10 |
+
### Stufe 2: Security & Quality Checks (Lokal)
|
| 11 |
+
### Stufe 3: GitHub Actions Simulation (mit `act`)
|
| 12 |
+
### Stufe 4: Live Test auf GitHub (Push/PR)
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## 🔧 Stufe 1: Lokale Docker Tests
|
| 17 |
+
|
| 18 |
+
### 1.1 Environment Setup testen
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
# 1. .env Datei erstellen
|
| 22 |
+
cp .env.example .env
|
| 23 |
+
|
| 24 |
+
# 2. .env mit echten Werten füllen (mindestens für Tests)
|
| 25 |
+
nano .env
|
| 26 |
+
|
| 27 |
+
# Mindestens diese Werte setzen:
|
| 28 |
+
# OPENROUTER_API_KEY=dein-echter-key
|
| 29 |
+
# COLOSSUS_API_KEY=dein-echter-key
|
| 30 |
+
# SECRET_KEY=test-secret-key-123
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
### 1.2 Development Build testen
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
# Docker Compose Development Build
|
| 37 |
+
docker-compose up --build
|
| 38 |
+
|
| 39 |
+
# In separatem Terminal:
|
| 40 |
+
# Backend Health Check
|
| 41 |
+
curl http://localhost:8000/health
|
| 42 |
+
|
| 43 |
+
# Erwartete Ausgabe:
|
| 44 |
+
# {"status":"healthy","timestamp":"2025-11-18T10:38:00.000000"}
|
| 45 |
+
|
| 46 |
+
# Frontend erreichbar?
|
| 47 |
+
curl http://localhost:5173
|
| 48 |
+
|
| 49 |
+
# API Docs erreichbar?
|
| 50 |
+
curl http://localhost:8000/docs
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
**Erwartetes Ergebnis:**
|
| 54 |
+
- ✅ Backend startet ohne Fehler
|
| 55 |
+
- ✅ Frontend startet ohne Fehler
|
| 56 |
+
- ✅ PostgreSQL läuft
|
| 57 |
+
- ✅ Health Check returns `{"status":"healthy"}`
|
| 58 |
+
|
| 59 |
+
### 1.3 Production Build testen
|
| 60 |
+
|
| 61 |
+
```bash
|
| 62 |
+
# Docker Compose Production Build
|
| 63 |
+
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --build
|
| 64 |
+
|
| 65 |
+
# Health Checks
|
| 66 |
+
curl http://localhost:8000/health # Backend
|
| 67 |
+
curl http://localhost/ # Frontend (Port 80!)
|
| 68 |
+
|
| 69 |
+
# API Docs (Production)
|
| 70 |
+
curl http://localhost:8000/docs
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
**Wichtige Unterschiede:**
|
| 74 |
+
- Frontend läuft auf Port **80** (nicht 5173)
|
| 75 |
+
- Production builds sind optimiert (keine dev dependencies)
|
| 76 |
+
- Uvicorn läuft mit 4 Workers
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
## 🔐 Stufe 2: Security & Quality Checks (Lokal)
|
| 81 |
+
|
| 82 |
+
### 2.1 Gitleaks Secret Scanning
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
# Vollständiger Scan des Repositories
|
| 86 |
+
gitleaks detect --source . --verbose
|
| 87 |
+
|
| 88 |
+
# Erwartete Ausgabe:
|
| 89 |
+
# ○
|
| 90 |
+
# ████████╗██████╗ ██╗ ██╗███████╗███████╗██╗ ███████╗ █████╗ ██╗ ██╗███████╗
|
| 91 |
+
# ╚══██╔══╝██╔══██╗██║ ██║██╔════╝██╔════╝██║ ██╔════╝██╔══██╗██║ ██╔╝██╔════╝
|
| 92 |
+
# ██║ ██████╔╝██║ ██║█████╗ █████╗ ██║ █████╗ ███████║█████╔╝ ███████╗
|
| 93 |
+
# ...
|
| 94 |
+
#
|
| 95 |
+
# No leaks found ✅
|
| 96 |
+
|
| 97 |
+
# Mit Report-Datei
|
| 98 |
+
gitleaks detect --source . --report-path gitleaks-report.json
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
**Was wird gescannt:**
|
| 102 |
+
- API Keys (OpenRouter, Colossus, etc.)
|
| 103 |
+
- Database Passwords
|
| 104 |
+
- Secret Keys
|
| 105 |
+
- JWT Tokens
|
| 106 |
+
- SSH Private Keys
|
| 107 |
+
|
| 108 |
+
**Bei Fund:**
|
| 109 |
+
```bash
|
| 110 |
+
# Secrets gefunden!
|
| 111 |
+
# Ausgabe zeigt Datei + Zeile + Secret-Typ
|
| 112 |
+
|
| 113 |
+
# Sofort beheben:
|
| 114 |
+
# 1. Secret aus Datei entfernen
|
| 115 |
+
# 2. .gitignore prüfen
|
| 116 |
+
# 3. Erneut scannen
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### 2.2 Dependency Security Audit
|
| 120 |
+
|
| 121 |
+
```bash
|
| 122 |
+
# Frontend Dependencies
|
| 123 |
+
cd frontend
|
| 124 |
+
npm audit --audit-level=moderate
|
| 125 |
+
|
| 126 |
+
# Erwartete Ausgabe:
|
| 127 |
+
# found 0 vulnerabilities ✅
|
| 128 |
+
|
| 129 |
+
# Bei Vulnerabilities:
|
| 130 |
+
npm audit fix
|
| 131 |
+
|
| 132 |
+
# Backend Dependencies
|
| 133 |
+
cd ../backend
|
| 134 |
+
pip install pip-audit
|
| 135 |
+
pip-audit
|
| 136 |
+
|
| 137 |
+
# Erwartete Ausgabe:
|
| 138 |
+
# No known vulnerabilities found ✅
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
### 2.3 Linting & Formatting
|
| 142 |
+
|
| 143 |
+
```bash
|
| 144 |
+
# Frontend (ESLint + Prettier)
|
| 145 |
+
cd frontend
|
| 146 |
+
npm run lint # ESLint Check
|
| 147 |
+
npm run format:check # Prettier Check
|
| 148 |
+
|
| 149 |
+
# Auto-Fix
|
| 150 |
+
npm run lint:fix
|
| 151 |
+
npm run format
|
| 152 |
+
|
| 153 |
+
# Backend (Ruff)
|
| 154 |
+
cd ../backend
|
| 155 |
+
ruff check . # Lint Check
|
| 156 |
+
ruff format . # Format Code
|
| 157 |
+
|
| 158 |
+
# TypeScript Check
|
| 159 |
+
cd ../frontend
|
| 160 |
+
npm run type-check
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
**Erwartetes Ergebnis:**
|
| 164 |
+
- ✅ 0 ESLint errors
|
| 165 |
+
- ✅ 0 Ruff errors
|
| 166 |
+
- ✅ 0 TypeScript errors
|
| 167 |
+
- ✅ Code korrekt formatiert
|
| 168 |
+
|
| 169 |
+
---
|
| 170 |
+
|
| 171 |
+
## 🎬 Stufe 3: GitHub Actions Simulation (mit `act`)
|
| 172 |
+
|
| 173 |
+
### 3.1 `act` installieren (GitHub Actions lokal ausführen)
|
| 174 |
+
|
| 175 |
+
```bash
|
| 176 |
+
# Installation (Linux/macOS)
|
| 177 |
+
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
|
| 178 |
+
|
| 179 |
+
# Oder via Package Manager
|
| 180 |
+
# Ubuntu/Debian
|
| 181 |
+
sudo apt install act
|
| 182 |
+
|
| 183 |
+
# macOS
|
| 184 |
+
brew install act
|
| 185 |
+
|
| 186 |
+
# Arch Linux
|
| 187 |
+
sudo pacman -S act
|
| 188 |
+
|
| 189 |
+
# Version prüfen
|
| 190 |
+
act --version
|
| 191 |
+
```
|
| 192 |
+
|
| 193 |
+
### 3.2 GitHub Actions Workflow lokal testen
|
| 194 |
+
|
| 195 |
+
```bash
|
| 196 |
+
# Alle Jobs auflisten
|
| 197 |
+
act -l
|
| 198 |
+
|
| 199 |
+
# Erwartete Ausgabe:
|
| 200 |
+
# Stage Job ID Job name Workflow name Workflow file
|
| 201 |
+
# 0 security security SAAP CI/CD Pipeline ci-cd-pipeline.yml
|
| 202 |
+
# 0 lint-backend lint-backend SAAP CI/CD Pipeline ci-cd-pipeline.yml
|
| 203 |
+
# 0 lint-frontend lint-frontend SAAP CI/CD Pipeline ci-cd-pipeline.yml
|
| 204 |
+
# 1 test-backend test-backend SAAP CI/CD Pipeline ci-cd-pipeline.yml
|
| 205 |
+
# 1 test-frontend test-frontend SAAP CI/CD Pipeline ci-cd-pipeline.yml
|
| 206 |
+
# 2 build-backend build-backend SAAP CI/CD Pipeline ci-cd-pipeline.yml
|
| 207 |
+
# 2 build-frontend build-frontend SAAP CI/CD Pipeline ci-cd-pipeline.yml
|
| 208 |
+
|
| 209 |
+
# Komplette Pipeline ausführen (ohne Docker Build/Push)
|
| 210 |
+
act push
|
| 211 |
+
|
| 212 |
+
# Einzelnen Job testen
|
| 213 |
+
act -j security # Nur Security Checks
|
| 214 |
+
act -j lint-backend # Nur Backend Linting
|
| 215 |
+
act -j lint-frontend # Nur Frontend Linting
|
| 216 |
+
|
| 217 |
+
# Mit GitHub Secrets (simuliert)
|
| 218 |
+
act -s GITHUB_TOKEN=fake-token-for-testing
|
| 219 |
+
|
| 220 |
+
# Dry-Run (zeigt was passieren würde)
|
| 221 |
+
act -n
|
| 222 |
+
```
|
| 223 |
+
|
| 224 |
+
### 3.3 Docker Build lokal simulieren
|
| 225 |
+
|
| 226 |
+
```bash
|
| 227 |
+
# Backend Build testen
|
| 228 |
+
docker build -t saap-backend-test \
|
| 229 |
+
--build-arg PYTHON_VERSION=3.10 \
|
| 230 |
+
-f backend/Dockerfile \
|
| 231 |
+
./backend
|
| 232 |
+
|
| 233 |
+
# Frontend Build testen
|
| 234 |
+
docker build -t saap-frontend-test \
|
| 235 |
+
--build-arg NODE_VERSION=20 \
|
| 236 |
+
-f frontend/Dockerfile \
|
| 237 |
+
./frontend
|
| 238 |
+
|
| 239 |
+
# Multi-Architecture Build simulieren (buildx)
|
| 240 |
+
docker buildx create --use --name multiarch
|
| 241 |
+
docker buildx build \
|
| 242 |
+
--platform linux/amd64,linux/arm64 \
|
| 243 |
+
-t saap-backend-multiarch \
|
| 244 |
+
-f backend/Dockerfile \
|
| 245 |
+
./backend \
|
| 246 |
+
--load
|
| 247 |
+
|
| 248 |
+
# Images prüfen
|
| 249 |
+
docker images | grep saap
|
| 250 |
+
```
|
| 251 |
+
|
| 252 |
+
**Erwartetes Ergebnis:**
|
| 253 |
+
- ✅ Backend Image: ~200-300 MB
|
| 254 |
+
- ✅ Frontend Image: ~50-100 MB
|
| 255 |
+
- ✅ Keine Build-Fehler
|
| 256 |
+
- ✅ Health Check im Container funktioniert
|
| 257 |
+
|
| 258 |
+
---
|
| 259 |
+
|
| 260 |
+
## 🚀 Stufe 4: Live Test auf GitHub
|
| 261 |
+
|
| 262 |
+
### 4.1 Vorbereitung
|
| 263 |
+
|
| 264 |
+
```bash
|
| 265 |
+
# 1. Sicherstellen, dass .env NICHT committed ist
|
| 266 |
+
git status | grep .env
|
| 267 |
+
|
| 268 |
+
# Wenn .env gelistet wird:
|
| 269 |
+
git reset HEAD backend/.env
|
| 270 |
+
echo "backend/.env" >> .gitignore
|
| 271 |
+
|
| 272 |
+
# 2. Letzte Security-Checks
|
| 273 |
+
gitleaks detect --source . --verbose
|
| 274 |
+
npm audit --audit-level=moderate
|
| 275 |
+
|
| 276 |
+
# 3. Alle Änderungen committen
|
| 277 |
+
git add .
|
| 278 |
+
git commit -m "feat: add CI/CD pipeline and Docker deployment"
|
| 279 |
+
|
| 280 |
+
# 4. Feature Branch erstellen (NICHT direkt auf main)
|
| 281 |
+
git checkout -b feature/cicd-pipeline
|
| 282 |
+
```
|
| 283 |
+
|
| 284 |
+
### 4.2 Ersten Push testen
|
| 285 |
+
|
| 286 |
+
```bash
|
| 287 |
+
# Push zu GitHub
|
| 288 |
+
git push origin feature/cicd-pipeline
|
| 289 |
+
|
| 290 |
+
# GitHub öffnen und Pipeline beobachten:
|
| 291 |
+
# https://github.com/satwareAG/saap/actions
|
| 292 |
+
```
|
| 293 |
+
|
| 294 |
+
**Was passiert auf GitHub:**
|
| 295 |
+
1. ✅ **Security Job** läuft (Gitleaks, npm audit)
|
| 296 |
+
2. ✅ **Lint Jobs** laufen (ESLint, Ruff, Prettier)
|
| 297 |
+
3. ✅ **Test Jobs** laufen (Unit Tests, Falls vorhanden)
|
| 298 |
+
4. ✅ **Build Jobs** laufen (Docker Multi-Arch Build)
|
| 299 |
+
5. ✅ **Push to Registry** (ghcr.io) - NUR wenn auf main/develop Branch
|
| 300 |
+
|
| 301 |
+
### 4.3 Pull Request erstellen
|
| 302 |
+
|
| 303 |
+
```bash
|
| 304 |
+
# PR von feature/cicd-pipeline → main erstellen
|
| 305 |
+
# GitHub Web UI verwenden ODER:
|
| 306 |
+
|
| 307 |
+
gh pr create \
|
| 308 |
+
--title "Add CI/CD Pipeline and Docker Deployment" \
|
| 309 |
+
--body "Adds complete CI/CD pipeline with GitHub Actions" \
|
| 310 |
+
--base main \
|
| 311 |
+
--head feature/cicd-pipeline
|
| 312 |
+
```
|
| 313 |
+
|
| 314 |
+
**CI/CD Workflow bei PR:**
|
| 315 |
+
- Läuft ALLE Checks (Security, Lint, Test, Build)
|
| 316 |
+
- Baut Docker Images (aber pusht NICHT zu Registry)
|
| 317 |
+
- Zeigt Ergebnisse im PR
|
| 318 |
+
|
| 319 |
+
### 4.4 GitHub Container Registry prüfen
|
| 320 |
+
|
| 321 |
+
```bash
|
| 322 |
+
# Nach erfolgreichem Push zu main/develop:
|
| 323 |
+
# Images sollten verfügbar sein:
|
| 324 |
+
|
| 325 |
+
# Backend Image
|
| 326 |
+
docker pull ghcr.io/satwareag/saap/backend:latest
|
| 327 |
+
|
| 328 |
+
# Frontend Image
|
| 329 |
+
docker pull ghcr.io/satwareag/saap/frontend:latest
|
| 330 |
+
|
| 331 |
+
# Spezifische Version (Commit SHA)
|
| 332 |
+
docker pull ghcr.io/satwareag/saap/backend:abc1234
|
| 333 |
+
|
| 334 |
+
# Images lokal testen
|
| 335 |
+
docker run -p 8000:8000 ghcr.io/satwareag/saap/backend:latest
|
| 336 |
+
```
|
| 337 |
+
|
| 338 |
+
---
|
| 339 |
+
|
| 340 |
+
## ✅ Vollständige Test-Checkliste
|
| 341 |
+
|
| 342 |
+
### Pre-Push Checklist
|
| 343 |
+
|
| 344 |
+
```bash
|
| 345 |
+
# 1. Environment Setup
|
| 346 |
+
[ ] .env erstellt und konfiguriert
|
| 347 |
+
[ ] .env in .gitignore
|
| 348 |
+
|
| 349 |
+
# 2. Lokale Docker Tests
|
| 350 |
+
[ ] docker-compose up --build funktioniert
|
| 351 |
+
[ ] Backend Health Check: curl http://localhost:8000/health
|
| 352 |
+
[ ] Frontend erreichbar: curl http://localhost:5173
|
| 353 |
+
[ ] Production Build: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
|
| 354 |
+
|
| 355 |
+
# 3. Security Checks
|
| 356 |
+
[ ] gitleaks detect --source . --verbose → No leaks found
|
| 357 |
+
[ ] npm audit --audit-level=moderate → 0 vulnerabilities
|
| 358 |
+
[ ] pip-audit → No vulnerabilities
|
| 359 |
+
|
| 360 |
+
# 4. Quality Checks
|
| 361 |
+
[ ] npm run lint (Frontend)
|
| 362 |
+
[ ] ruff check . (Backend)
|
| 363 |
+
[ ] npm run type-check (TypeScript)
|
| 364 |
+
[ ] npm run format:check (Prettier)
|
| 365 |
+
|
| 366 |
+
# 5. Docker Build Tests
|
| 367 |
+
[ ] docker build backend/Dockerfile funktioniert
|
| 368 |
+
[ ] docker build frontend/Dockerfile funktioniert
|
| 369 |
+
[ ] Images starten ohne Fehler
|
| 370 |
+
|
| 371 |
+
# 6. GitHub Actions Simulation (optional)
|
| 372 |
+
[ ] act -j security funktioniert
|
| 373 |
+
[ ] act -j lint-backend funktioniert
|
| 374 |
+
[ ] act -j lint-frontend funktioniert
|
| 375 |
+
```
|
| 376 |
+
|
| 377 |
+
### Post-Push Checklist
|
| 378 |
+
|
| 379 |
+
```bash
|
| 380 |
+
# Nach Push zu GitHub
|
| 381 |
+
[ ] GitHub Actions Workflow startet
|
| 382 |
+
[ ] Alle Jobs grün (Security, Lint, Test, Build)
|
| 383 |
+
[ ] Keine Fehler in Logs
|
| 384 |
+
[ ] Docker Images in ghcr.io verfügbar (bei main/develop)
|
| 385 |
+
[ ] Images können gepullt werden
|
| 386 |
+
[ ] Production Deployment funktioniert
|
| 387 |
+
```
|
| 388 |
+
|
| 389 |
+
---
|
| 390 |
+
|
| 391 |
+
## 🚨 Troubleshooting
|
| 392 |
+
|
| 393 |
+
### Problem: `act` findet Docker nicht
|
| 394 |
+
|
| 395 |
+
```bash
|
| 396 |
+
# Docker läuft?
|
| 397 |
+
docker ps
|
| 398 |
+
|
| 399 |
+
# Docker Socket Permission
|
| 400 |
+
sudo usermod -aG docker $USER
|
| 401 |
+
newgrp docker
|
| 402 |
+
```
|
| 403 |
+
|
| 404 |
+
### Problem: GitHub Actions schlägt fehl (lokaler Test OK)
|
| 405 |
+
|
| 406 |
+
```bash
|
| 407 |
+
# Secrets in GitHub konfiguriert?
|
| 408 |
+
# Settings → Secrets and variables → Actions
|
| 409 |
+
|
| 410 |
+
# Branch Protection Rules checken
|
| 411 |
+
# Settings → Branches → Branch protection rules
|
| 412 |
+
```
|
| 413 |
+
|
| 414 |
+
### Problem: Docker Build schlägt fehl im CI/CD
|
| 415 |
+
|
| 416 |
+
```bash
|
| 417 |
+
# .dockerignore prüfen
|
| 418 |
+
cat backend/.dockerignore
|
| 419 |
+
cat frontend/.dockerignore
|
| 420 |
+
|
| 421 |
+
# Build Logs in GitHub Actions ansehen
|
| 422 |
+
# Actions → Workflow → Failed Job → Logs
|
| 423 |
+
```
|
| 424 |
+
|
| 425 |
+
### Problem: Images können nicht gepusht werden
|
| 426 |
+
|
| 427 |
+
```bash
|
| 428 |
+
# GitHub Package Permission
|
| 429 |
+
# Settings → Actions → General → Workflow permissions
|
| 430 |
+
# ✅ Read and write permissions
|
| 431 |
+
|
| 432 |
+
# Container Registry Visibility
|
| 433 |
+
# GitHub → Packages → saap/backend → Package settings
|
| 434 |
+
```
|
| 435 |
+
|
| 436 |
+
---
|
| 437 |
+
|
| 438 |
+
## 📊 Erwartete Test-Ergebnisse
|
| 439 |
+
|
| 440 |
+
### Erfolgreicher Lokaler Test
|
| 441 |
+
|
| 442 |
+
```
|
| 443 |
+
✅ docker-compose up → Alle Services starten
|
| 444 |
+
✅ Health Check → {"status":"healthy"}
|
| 445 |
+
✅ Gitleaks → No leaks found
|
| 446 |
+
✅ npm audit → 0 vulnerabilities
|
| 447 |
+
✅ ESLint → 0 errors
|
| 448 |
+
✅ Ruff → 0 errors
|
| 449 |
+
✅ Docker Build → Images erstellt
|
| 450 |
+
✅ act → Alle Jobs grün
|
| 451 |
+
```
|
| 452 |
+
|
| 453 |
+
### Erfolgreicher GitHub Test
|
| 454 |
+
|
| 455 |
+
```
|
| 456 |
+
✅ Push → Workflow startet automatisch
|
| 457 |
+
✅ Security Job → Passed (30s)
|
| 458 |
+
✅ Lint Backend → Passed (45s)
|
| 459 |
+
✅ Lint Frontend → Passed (1min)
|
| 460 |
+
✅ Test Backend → Passed (2min)
|
| 461 |
+
✅ Test Frontend → Passed (1min)
|
| 462 |
+
✅ Build Backend → Passed (5min)
|
| 463 |
+
✅ Build Frontend → Passed (4min)
|
| 464 |
+
✅ Push to Registry → Passed (2min)
|
| 465 |
+
|
| 466 |
+
Total: ~15 Minuten
|
| 467 |
+
```
|
| 468 |
+
|
| 469 |
+
---
|
| 470 |
+
|
| 471 |
+
## 🎯 Quick Start Testing
|
| 472 |
+
|
| 473 |
+
```bash
|
| 474 |
+
# Minimales Testing (5 Minuten)
|
| 475 |
+
docker-compose up --build # 2min
|
| 476 |
+
curl http://localhost:8000/health # 1s
|
| 477 |
+
gitleaks detect --source . --verbose # 30s
|
| 478 |
+
npm audit --audit-level=moderate # 30s
|
| 479 |
+
docker-compose down # 10s
|
| 480 |
+
|
| 481 |
+
# Vollständiges Testing (30 Minuten)
|
| 482 |
+
# Alle Schritte aus Pre-Push Checklist + act Simulation
|
| 483 |
+
```
|
| 484 |
+
|
| 485 |
+
---
|
| 486 |
+
|
| 487 |
+
## 📚 Weitere Ressourcen
|
| 488 |
+
|
| 489 |
+
- **act Documentation**: https://github.com/nektos/act
|
| 490 |
+
- **GitHub Actions Docs**: https://docs.github.com/en/actions
|
| 491 |
+
- **Docker Buildx**: https://docs.docker.com/buildx/working-with-buildx/
|
| 492 |
+
- **Gitleaks**: https://github.com/gitleaks/gitleaks
|
| 493 |
+
|
| 494 |
+
## 🆘 Support
|
| 495 |
+
|
| 496 |
+
Bei Problemen:
|
| 497 |
+
1. GitHub Actions Logs analysieren
|
| 498 |
+
2. Lokale Docker Logs prüfen: `docker-compose logs`
|
| 499 |
+
3. Issue erstellen: https://github.com/satwareAG/saap/issues
|
backend/.dockerignore
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================================
|
| 2 |
+
# Backend .dockerignore
|
| 3 |
+
# ==========================================
|
| 4 |
+
|
| 5 |
+
# Environment files (SECURITY - Never include in image)
|
| 6 |
+
.env
|
| 7 |
+
.env.*
|
| 8 |
+
!.env.example
|
| 9 |
+
|
| 10 |
+
# Python cache
|
| 11 |
+
__pycache__/
|
| 12 |
+
*.py[cod]
|
| 13 |
+
*$py.class
|
| 14 |
+
*.so
|
| 15 |
+
.Python
|
| 16 |
+
*.egg-info/
|
| 17 |
+
dist/
|
| 18 |
+
build/
|
| 19 |
+
|
| 20 |
+
# Virtual environments
|
| 21 |
+
venv/
|
| 22 |
+
env/
|
| 23 |
+
ENV/
|
| 24 |
+
.venv/
|
| 25 |
+
|
| 26 |
+
# IDE files
|
| 27 |
+
.vscode/
|
| 28 |
+
.idea/
|
| 29 |
+
*.swp
|
| 30 |
+
*.swo
|
| 31 |
+
*~
|
| 32 |
+
|
| 33 |
+
# Testing
|
| 34 |
+
.pytest_cache/
|
| 35 |
+
.coverage
|
| 36 |
+
htmlcov/
|
| 37 |
+
.tox/
|
| 38 |
+
.hypothesis/
|
| 39 |
+
|
| 40 |
+
# Logs
|
| 41 |
+
logs/
|
| 42 |
+
*.log
|
| 43 |
+
|
| 44 |
+
# Database files
|
| 45 |
+
*.db
|
| 46 |
+
*.sqlite
|
| 47 |
+
*.sqlite3
|
| 48 |
+
|
| 49 |
+
# Git
|
| 50 |
+
.git/
|
| 51 |
+
.gitignore
|
| 52 |
+
.gitattributes
|
| 53 |
+
|
| 54 |
+
# Documentation (not needed in runtime)
|
| 55 |
+
*.md
|
| 56 |
+
docs/
|
| 57 |
+
|
| 58 |
+
# CI/CD
|
| 59 |
+
.github/
|
| 60 |
+
.gitlab-ci.yml
|
| 61 |
+
|
| 62 |
+
# Development scripts
|
| 63 |
+
scripts/
|
| 64 |
+
test_*.py
|
| 65 |
+
|
| 66 |
+
# Backups
|
| 67 |
+
*_backup/
|
| 68 |
+
*.bak
|
| 69 |
+
*.backup
|
| 70 |
+
|
| 71 |
+
# Temporary files
|
| 72 |
+
*.tmp
|
| 73 |
+
*.temp
|
| 74 |
+
.DS_Store
|
| 75 |
+
Thumbs.db
|
backend/Dockerfile
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================================
|
| 2 |
+
# SAAP Backend Dockerfile (Multi-Stage Build)
|
| 3 |
+
# Python 3.11 + FastAPI + PostgreSQL
|
| 4 |
+
# ==========================================
|
| 5 |
+
|
| 6 |
+
# ==========================================
|
| 7 |
+
# Stage 1: Builder (Dependencies Installation)
|
| 8 |
+
# ==========================================
|
| 9 |
+
FROM python:3.11-slim AS builder
|
| 10 |
+
|
| 11 |
+
LABEL maintainer="SATWARE AG <info@satware.com>"
|
| 12 |
+
LABEL description="SAAP Backend - satware Autonomous Agent Platform"
|
| 13 |
+
|
| 14 |
+
# Set working directory
|
| 15 |
+
WORKDIR /app
|
| 16 |
+
|
| 17 |
+
# Install system dependencies for building Python packages
|
| 18 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 19 |
+
gcc \
|
| 20 |
+
g++ \
|
| 21 |
+
libpq-dev \
|
| 22 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
+
|
| 24 |
+
# Copy requirements first for better caching
|
| 25 |
+
COPY requirements.txt .
|
| 26 |
+
|
| 27 |
+
# Install Python dependencies
|
| 28 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 29 |
+
pip install --no-cache-dir -r requirements.txt
|
| 30 |
+
|
| 31 |
+
# ==========================================
|
| 32 |
+
# Stage 2: Runtime (Minimal Production Image)
|
| 33 |
+
# ==========================================
|
| 34 |
+
FROM python:3.11-slim AS runtime
|
| 35 |
+
|
| 36 |
+
# Set working directory
|
| 37 |
+
WORKDIR /app
|
| 38 |
+
|
| 39 |
+
# Install runtime dependencies only
|
| 40 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 41 |
+
libpq5 \
|
| 42 |
+
curl \
|
| 43 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 44 |
+
|
| 45 |
+
# Copy installed packages from builder
|
| 46 |
+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
| 47 |
+
COPY --from=builder /usr/local/bin /usr/local/bin
|
| 48 |
+
|
| 49 |
+
# Create non-root user for security
|
| 50 |
+
RUN groupadd -r saap && useradd -r -g saap saap
|
| 51 |
+
|
| 52 |
+
# Copy application code
|
| 53 |
+
COPY --chown=saap:saap . .
|
| 54 |
+
|
| 55 |
+
# Create necessary directories
|
| 56 |
+
RUN mkdir -p logs && chown -R saap:saap logs
|
| 57 |
+
|
| 58 |
+
# Switch to non-root user
|
| 59 |
+
USER saap
|
| 60 |
+
|
| 61 |
+
# Environment variables
|
| 62 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 63 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 64 |
+
PYTHONPATH=/app
|
| 65 |
+
|
| 66 |
+
# Expose port
|
| 67 |
+
EXPOSE 8000
|
| 68 |
+
|
| 69 |
+
# Health check
|
| 70 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
| 71 |
+
CMD curl -f http://localhost:8000/health || exit 1
|
| 72 |
+
|
| 73 |
+
# Run application
|
| 74 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]
|
backend/database/models.py
CHANGED
|
@@ -7,6 +7,7 @@ from sqlalchemy import Column, Integer, String, Text, DateTime, Float, Boolean,
|
|
| 7 |
from sqlalchemy.ext.declarative import declarative_base
|
| 8 |
from sqlalchemy.orm import relationship
|
| 9 |
from sqlalchemy.sql import func
|
|
|
|
| 10 |
from datetime import datetime
|
| 11 |
from typing import Dict, Any, Optional
|
| 12 |
import json
|
|
@@ -44,9 +45,9 @@ class DBAgent(Base):
|
|
| 44 |
# Performance Metrics (stored as JSON)
|
| 45 |
metrics = Column(JSON, nullable=True) # Performance metrics object
|
| 46 |
|
| 47 |
-
# Metadata
|
| 48 |
-
created_at = Column(
|
| 49 |
-
updated_at = Column(
|
| 50 |
tags = Column(JSON, nullable=True) # List of tags
|
| 51 |
|
| 52 |
# 🔧 FIXED: Relationships WITH back_populates to COORDINATE bidirectional relationships
|
|
@@ -209,7 +210,7 @@ class DBChatMessage(Base):
|
|
| 209 |
|
| 210 |
# Message Metadata (renamed from 'metadata' to avoid SQLAlchemy reserved keyword)
|
| 211 |
message_metadata = Column(JSON, nullable=True) # Additional metadata (model, temperature, etc.)
|
| 212 |
-
created_at = Column(
|
| 213 |
|
| 214 |
# 🔧 FIXED: Relationship WITH back_populates to COORDINATE bidirectional relationship
|
| 215 |
agent = relationship(
|
|
@@ -238,9 +239,9 @@ class DBAgentSession(Base):
|
|
| 238 |
# Foreign Key to Agent
|
| 239 |
agent_id = Column(String(100), ForeignKey("agents.id"), nullable=False, index=True)
|
| 240 |
|
| 241 |
-
# Session Information
|
| 242 |
-
session_start = Column(
|
| 243 |
-
session_end = Column(
|
| 244 |
duration_seconds = Column(Integer, nullable=True) # Calculated session duration
|
| 245 |
|
| 246 |
# Session Metrics
|
|
@@ -300,8 +301,8 @@ class DBSystemLog(Base):
|
|
| 300 |
# Additional Data
|
| 301 |
extra_data = Column(JSON, nullable=True) # Additional structured data
|
| 302 |
|
| 303 |
-
# Timestamp
|
| 304 |
-
created_at = Column(
|
| 305 |
|
| 306 |
# Indexes for performance
|
| 307 |
__table_args__ = (
|
|
@@ -335,8 +336,8 @@ class DBHealthCheck(Base):
|
|
| 335 |
details = Column(JSON, nullable=True) # Additional health check data
|
| 336 |
error_message = Column(Text, nullable=True)
|
| 337 |
|
| 338 |
-
# Timestamp
|
| 339 |
-
created_at = Column(
|
| 340 |
|
| 341 |
# Indexes for performance
|
| 342 |
__table_args__ = (
|
|
|
|
| 7 |
from sqlalchemy.ext.declarative import declarative_base
|
| 8 |
from sqlalchemy.orm import relationship
|
| 9 |
from sqlalchemy.sql import func
|
| 10 |
+
from sqlalchemy.dialects.postgresql import TIMESTAMP
|
| 11 |
from datetime import datetime
|
| 12 |
from typing import Dict, Any, Optional
|
| 13 |
import json
|
|
|
|
| 45 |
# Performance Metrics (stored as JSON)
|
| 46 |
metrics = Column(JSON, nullable=True) # Performance metrics object
|
| 47 |
|
| 48 |
+
# Metadata (🔧 FIXED: TIMESTAMP WITH TIME ZONE for timezone-aware datetimes)
|
| 49 |
+
created_at = Column(TIMESTAMP(timezone=True), default=func.now(), nullable=False, index=True)
|
| 50 |
+
updated_at = Column(TIMESTAMP(timezone=True), default=func.now(), onupdate=func.now(), nullable=False)
|
| 51 |
tags = Column(JSON, nullable=True) # List of tags
|
| 52 |
|
| 53 |
# 🔧 FIXED: Relationships WITH back_populates to COORDINATE bidirectional relationships
|
|
|
|
| 210 |
|
| 211 |
# Message Metadata (renamed from 'metadata' to avoid SQLAlchemy reserved keyword)
|
| 212 |
message_metadata = Column(JSON, nullable=True) # Additional metadata (model, temperature, etc.)
|
| 213 |
+
created_at = Column(TIMESTAMP(timezone=True), default=func.now(), nullable=False, index=True)
|
| 214 |
|
| 215 |
# 🔧 FIXED: Relationship WITH back_populates to COORDINATE bidirectional relationship
|
| 216 |
agent = relationship(
|
|
|
|
| 239 |
# Foreign Key to Agent
|
| 240 |
agent_id = Column(String(100), ForeignKey("agents.id"), nullable=False, index=True)
|
| 241 |
|
| 242 |
+
# Session Information (🔧 FIXED: TIMESTAMP WITH TIME ZONE)
|
| 243 |
+
session_start = Column(TIMESTAMP(timezone=True), default=func.now(), nullable=False, index=True)
|
| 244 |
+
session_end = Column(TIMESTAMP(timezone=True), nullable=True, index=True)
|
| 245 |
duration_seconds = Column(Integer, nullable=True) # Calculated session duration
|
| 246 |
|
| 247 |
# Session Metrics
|
|
|
|
| 301 |
# Additional Data
|
| 302 |
extra_data = Column(JSON, nullable=True) # Additional structured data
|
| 303 |
|
| 304 |
+
# Timestamp (🔧 FIXED: TIMESTAMP WITH TIME ZONE)
|
| 305 |
+
created_at = Column(TIMESTAMP(timezone=True), default=func.now(), nullable=False, index=True)
|
| 306 |
|
| 307 |
# Indexes for performance
|
| 308 |
__table_args__ = (
|
|
|
|
| 336 |
details = Column(JSON, nullable=True) # Additional health check data
|
| 337 |
error_message = Column(Text, nullable=True)
|
| 338 |
|
| 339 |
+
# Timestamp (🔧 FIXED: TIMESTAMP WITH TIME ZONE)
|
| 340 |
+
created_at = Column(TIMESTAMP(timezone=True), default=func.now(), nullable=False, index=True)
|
| 341 |
|
| 342 |
# Indexes for performance
|
| 343 |
__table_args__ = (
|
backend/main.py
CHANGED
|
@@ -276,6 +276,11 @@ async def root():
|
|
| 276 |
|
| 277 |
return base_info
|
| 278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
@app.get("/api/v1/health")
|
| 280 |
async def health_check():
|
| 281 |
"""Enhanced health check with provider status"""
|
|
|
|
| 276 |
|
| 277 |
return base_info
|
| 278 |
|
| 279 |
+
@app.get("/health")
|
| 280 |
+
async def health():
|
| 281 |
+
"""Simple health check for Docker/Kubernetes"""
|
| 282 |
+
return {"status": "healthy", "timestamp": datetime.utcnow().isoformat()}
|
| 283 |
+
|
| 284 |
@app.get("/api/v1/health")
|
| 285 |
async def health_check():
|
| 286 |
"""Enhanced health check with provider status"""
|
backend/requirements.txt
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SAAP Backend Requirements
|
| 2 |
+
# Python 3.10+
|
| 3 |
+
|
| 4 |
+
# FastAPI Framework
|
| 5 |
+
fastapi==0.109.0
|
| 6 |
+
uvicorn[standard]==0.27.0
|
| 7 |
+
python-multipart==0.0.6
|
| 8 |
+
|
| 9 |
+
# Pydantic for data validation (Python 3.13 compatible)
|
| 10 |
+
pydantic==2.10.3 # Updated for Python 3.13 compatibility
|
| 11 |
+
pydantic-settings==2.6.1 # Updated to match pydantic version
|
| 12 |
+
|
| 13 |
+
# Database (Python 3.13 compatible)
|
| 14 |
+
sqlalchemy==2.0.36 # Updated for Python 3.13 compatibility
|
| 15 |
+
alembic==1.14.0 # Updated to match SQLAlchemy version
|
| 16 |
+
aiosqlite==0.20.0 # Async SQLite driver (REQUIRED for async database operations)
|
| 17 |
+
greenlet>=3.0.0 # Required for SQLAlchemy async operations
|
| 18 |
+
psycopg2-binary==2.9.9 # PostgreSQL driver (works in Docker with Debian base)
|
| 19 |
+
asyncpg==0.30.0 # Async PostgreSQL driver (Python 3.13 compatible)
|
| 20 |
+
# Note: Using both psycopg2 (sync) and asyncpg (async) for PostgreSQL compatibility
|
| 21 |
+
|
| 22 |
+
# HTTP Clients
|
| 23 |
+
httpx==0.26.0
|
| 24 |
+
aiohttp==3.9.1
|
| 25 |
+
requests==2.31.0
|
| 26 |
+
|
| 27 |
+
# WebSocket
|
| 28 |
+
websockets==12.0
|
| 29 |
+
python-socketio==5.11.0
|
| 30 |
+
|
| 31 |
+
# Environment Variables
|
| 32 |
+
python-dotenv==1.0.0
|
| 33 |
+
|
| 34 |
+
# Async Support
|
| 35 |
+
asyncio==3.4.3
|
| 36 |
+
|
| 37 |
+
# Logging
|
| 38 |
+
colorlog==6.8.2
|
| 39 |
+
|
| 40 |
+
# Date/Time
|
| 41 |
+
python-dateutil==2.8.2
|
| 42 |
+
|
| 43 |
+
# JSON
|
| 44 |
+
orjson==3.9.12
|
| 45 |
+
|
| 46 |
+
# CORS (handled by FastAPI's built-in CORSMiddleware)
|
| 47 |
+
# No separate package needed - use fastapi.middleware.cors.CORSMiddleware
|
docker-compose.prod.yml
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
# ==========================================
|
| 4 |
+
# SAAP Docker Compose - Production Override
|
| 5 |
+
# Usage: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
| 6 |
+
# ==========================================
|
| 7 |
+
|
| 8 |
+
services:
|
| 9 |
+
# PostgreSQL - Production Settings
|
| 10 |
+
postgres:
|
| 11 |
+
environment:
|
| 12 |
+
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C --data-checksums"
|
| 13 |
+
volumes:
|
| 14 |
+
# Production: Use named volume without host mount
|
| 15 |
+
- postgres_data:/var/lib/postgresql/data
|
| 16 |
+
# Remove port exposure for security (only accessible within network)
|
| 17 |
+
ports: []
|
| 18 |
+
command:
|
| 19 |
+
- "postgres"
|
| 20 |
+
- "-c"
|
| 21 |
+
- "shared_buffers=256MB"
|
| 22 |
+
- "-c"
|
| 23 |
+
- "max_connections=100"
|
| 24 |
+
- "-c"
|
| 25 |
+
- "work_mem=4MB"
|
| 26 |
+
- "-c"
|
| 27 |
+
- "maintenance_work_mem=64MB"
|
| 28 |
+
- "-c"
|
| 29 |
+
- "effective_cache_size=1GB"
|
| 30 |
+
- "-c"
|
| 31 |
+
- "log_statement=all"
|
| 32 |
+
- "-c"
|
| 33 |
+
- "log_duration=on"
|
| 34 |
+
|
| 35 |
+
# Backend - Production Settings
|
| 36 |
+
backend:
|
| 37 |
+
# Use pre-built image from registry instead of building
|
| 38 |
+
image: ghcr.io/satwareag/saap/backend:latest
|
| 39 |
+
build:
|
| 40 |
+
context: ./backend
|
| 41 |
+
dockerfile: Dockerfile
|
| 42 |
+
target: runtime
|
| 43 |
+
environment:
|
| 44 |
+
# Override development settings
|
| 45 |
+
ENVIRONMENT: production
|
| 46 |
+
DEBUG: "false"
|
| 47 |
+
LOG_LEVEL: WARNING
|
| 48 |
+
|
| 49 |
+
# Production CORS (whitelist specific domains)
|
| 50 |
+
CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost}
|
| 51 |
+
|
| 52 |
+
# Production workers
|
| 53 |
+
WORKERS: ${WORKERS:-4}
|
| 54 |
+
|
| 55 |
+
volumes:
|
| 56 |
+
# Remove source code mount - use image only
|
| 57 |
+
- backend_logs:/app/logs
|
| 58 |
+
# Remove port exposure for security (accessed via frontend proxy)
|
| 59 |
+
ports: []
|
| 60 |
+
|
| 61 |
+
# Frontend - Production Settings
|
| 62 |
+
frontend:
|
| 63 |
+
# Use pre-built image from registry instead of building
|
| 64 |
+
image: ghcr.io/satwareag/saap/frontend:latest
|
| 65 |
+
build:
|
| 66 |
+
context: ./frontend
|
| 67 |
+
dockerfile: Dockerfile
|
| 68 |
+
target: runtime
|
| 69 |
+
environment:
|
| 70 |
+
# Production API URL (internal network)
|
| 71 |
+
VITE_API_BASE_URL: http://backend:8000
|
| 72 |
+
VITE_WS_URL: ws://backend:8000/ws
|
| 73 |
+
ports:
|
| 74 |
+
# Expose only frontend port
|
| 75 |
+
- "80:80"
|
| 76 |
+
|
| 77 |
+
# Production volumes with backup labels
|
| 78 |
+
volumes:
|
| 79 |
+
postgres_data:
|
| 80 |
+
driver: local
|
| 81 |
+
driver_opts:
|
| 82 |
+
type: none
|
| 83 |
+
o: bind
|
| 84 |
+
device: ${DATA_PATH:-./data}/postgres
|
| 85 |
+
labels:
|
| 86 |
+
- "backup.enable=true"
|
| 87 |
+
- "backup.frequency=daily"
|
| 88 |
+
backend_logs:
|
| 89 |
+
driver: local
|
| 90 |
+
driver_opts:
|
| 91 |
+
type: none
|
| 92 |
+
o: bind
|
| 93 |
+
device: ${DATA_PATH:-./data}/logs
|
| 94 |
+
labels:
|
| 95 |
+
- "backup.enable=true"
|
| 96 |
+
- "backup.frequency=weekly"
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================================
|
| 2 |
+
# SAAP Docker Compose - Development Setup
|
| 3 |
+
# ==========================================
|
| 4 |
+
|
| 5 |
+
services:
|
| 6 |
+
# PostgreSQL Database
|
| 7 |
+
postgres:
|
| 8 |
+
image: postgres:15-alpine
|
| 9 |
+
container_name: saap-postgres
|
| 10 |
+
environment:
|
| 11 |
+
POSTGRES_DB: ${POSTGRES_DB:-saap_db}
|
| 12 |
+
POSTGRES_USER: ${POSTGRES_USER:-saap_user}
|
| 13 |
+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-saap_password}
|
| 14 |
+
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
|
| 15 |
+
volumes:
|
| 16 |
+
- postgres_data:/var/lib/postgresql/data
|
| 17 |
+
ports:
|
| 18 |
+
- "${POSTGRES_PORT:-5432}:5432"
|
| 19 |
+
healthcheck:
|
| 20 |
+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-saap_user} -d ${POSTGRES_DB:-saap_db}"]
|
| 21 |
+
interval: 10s
|
| 22 |
+
timeout: 5s
|
| 23 |
+
retries: 5
|
| 24 |
+
networks:
|
| 25 |
+
- saap-network
|
| 26 |
+
restart: unless-stopped
|
| 27 |
+
|
| 28 |
+
# Backend API (FastAPI)
|
| 29 |
+
backend:
|
| 30 |
+
build:
|
| 31 |
+
context: ./backend
|
| 32 |
+
dockerfile: Dockerfile
|
| 33 |
+
container_name: saap-backend
|
| 34 |
+
env_file:
|
| 35 |
+
- backend/.env
|
| 36 |
+
environment:
|
| 37 |
+
# Database
|
| 38 |
+
DATABASE_URL: postgresql://${POSTGRES_USER:-saap_user}:${POSTGRES_PASSWORD:-saap_password}@postgres:5432/${POSTGRES_DB:-saap_db}
|
| 39 |
+
|
| 40 |
+
# API Keys (from .env file)
|
| 41 |
+
COLOSSUS_API_KEY: ${COLOSSUS_API_KEY}
|
| 42 |
+
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
|
| 43 |
+
|
| 44 |
+
# Application Settings
|
| 45 |
+
ENVIRONMENT: ${ENVIRONMENT:-production}
|
| 46 |
+
DEBUG: ${DEBUG:-false}
|
| 47 |
+
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
| 48 |
+
|
| 49 |
+
# CORS Settings
|
| 50 |
+
CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:5173,http://localhost:80}
|
| 51 |
+
|
| 52 |
+
# Security
|
| 53 |
+
SECRET_KEY: ${SECRET_KEY:-dev-secret-key-change-in-production}
|
| 54 |
+
|
| 55 |
+
volumes:
|
| 56 |
+
- ./backend:/app
|
| 57 |
+
- backend_logs:/app/logs
|
| 58 |
+
ports:
|
| 59 |
+
- "${BACKEND_PORT:-8000}:8000"
|
| 60 |
+
depends_on:
|
| 61 |
+
postgres:
|
| 62 |
+
condition: service_healthy
|
| 63 |
+
healthcheck:
|
| 64 |
+
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
| 65 |
+
interval: 30s
|
| 66 |
+
timeout: 10s
|
| 67 |
+
retries: 3
|
| 68 |
+
start_period: 40s
|
| 69 |
+
networks:
|
| 70 |
+
- saap-network
|
| 71 |
+
restart: unless-stopped
|
| 72 |
+
|
| 73 |
+
# Frontend (Vue.js + Nginx)
|
| 74 |
+
frontend:
|
| 75 |
+
build:
|
| 76 |
+
context: ./frontend
|
| 77 |
+
dockerfile: Dockerfile
|
| 78 |
+
container_name: saap-frontend
|
| 79 |
+
environment:
|
| 80 |
+
VITE_API_BASE_URL: ${VITE_API_BASE_URL:-http://localhost:8000}
|
| 81 |
+
VITE_WS_URL: ${VITE_WS_URL:-ws://localhost:8000/ws}
|
| 82 |
+
ports:
|
| 83 |
+
- "${FRONTEND_PORT:-5173}:80"
|
| 84 |
+
depends_on:
|
| 85 |
+
- backend
|
| 86 |
+
healthcheck:
|
| 87 |
+
test: ["CMD", "curl", "-f", "http://localhost/"]
|
| 88 |
+
interval: 30s
|
| 89 |
+
timeout: 10s
|
| 90 |
+
retries: 3
|
| 91 |
+
start_period: 40s
|
| 92 |
+
networks:
|
| 93 |
+
- saap-network
|
| 94 |
+
restart: unless-stopped
|
| 95 |
+
|
| 96 |
+
networks:
|
| 97 |
+
saap-network:
|
| 98 |
+
driver: bridge
|
| 99 |
+
|
| 100 |
+
volumes:
|
| 101 |
+
postgres_data:
|
| 102 |
+
driver: local
|
| 103 |
+
backend_logs:
|
| 104 |
+
driver: local
|
frontend/.dockerignore
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================================
|
| 2 |
+
# Frontend .dockerignore
|
| 3 |
+
# ==========================================
|
| 4 |
+
|
| 5 |
+
# Environment files (SECURITY - Never include in image)
|
| 6 |
+
.env
|
| 7 |
+
.env.*
|
| 8 |
+
!.env.example
|
| 9 |
+
|
| 10 |
+
# Node.js
|
| 11 |
+
node_modules/
|
| 12 |
+
npm-debug.log*
|
| 13 |
+
yarn-debug.log*
|
| 14 |
+
yarn-error.log*
|
| 15 |
+
pnpm-debug.log*
|
| 16 |
+
.pnpm-store/
|
| 17 |
+
|
| 18 |
+
# Build outputs (will be built in container)
|
| 19 |
+
dist/
|
| 20 |
+
dist-ssr/
|
| 21 |
+
.output/
|
| 22 |
+
.nuxt/
|
| 23 |
+
.next/
|
| 24 |
+
|
| 25 |
+
# IDE files
|
| 26 |
+
.vscode/
|
| 27 |
+
.idea/
|
| 28 |
+
*.swp
|
| 29 |
+
*.swo
|
| 30 |
+
*~
|
| 31 |
+
.DS_Store
|
| 32 |
+
|
| 33 |
+
# Testing
|
| 34 |
+
coverage/
|
| 35 |
+
.nyc_output/
|
| 36 |
+
tests/
|
| 37 |
+
*.test.js
|
| 38 |
+
*.test.ts
|
| 39 |
+
*.spec.js
|
| 40 |
+
*.spec.ts
|
| 41 |
+
|
| 42 |
+
# Git
|
| 43 |
+
.git/
|
| 44 |
+
.gitignore
|
| 45 |
+
.gitattributes
|
| 46 |
+
|
| 47 |
+
# Documentation (not needed in runtime)
|
| 48 |
+
*.md
|
| 49 |
+
docs/
|
| 50 |
+
README.md
|
| 51 |
+
|
| 52 |
+
# CI/CD
|
| 53 |
+
.github/
|
| 54 |
+
.gitlab-ci.yml
|
| 55 |
+
|
| 56 |
+
# Development tools
|
| 57 |
+
.eslintrc*
|
| 58 |
+
.prettierrc*
|
| 59 |
+
tsconfig.json
|
| 60 |
+
vite.config.ts
|
| 61 |
+
vitest.config.js
|
| 62 |
+
postcss.config.js
|
| 63 |
+
|
| 64 |
+
# Temporary files
|
| 65 |
+
*.tmp
|
| 66 |
+
*.temp
|
| 67 |
+
.cache/
|
| 68 |
+
Thumbs.db
|
frontend/Dockerfile
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================================
|
| 2 |
+
# SAAP Frontend Dockerfile (Multi-Stage Build)
|
| 3 |
+
# Vue.js 3 + TypeScript + Vite + Nginx
|
| 4 |
+
# ==========================================
|
| 5 |
+
|
| 6 |
+
# ==========================================
|
| 7 |
+
# Stage 1: Builder (Build Vue.js Application)
|
| 8 |
+
# ==========================================
|
| 9 |
+
FROM node:20-alpine AS builder
|
| 10 |
+
|
| 11 |
+
LABEL maintainer="SATWARE AG <info@satware.com>"
|
| 12 |
+
LABEL description="SAAP Frontend - satware Autonomous Agent Platform"
|
| 13 |
+
|
| 14 |
+
# Set working directory
|
| 15 |
+
WORKDIR /app
|
| 16 |
+
|
| 17 |
+
# Copy package files for dependency installation
|
| 18 |
+
COPY package*.json ./
|
| 19 |
+
|
| 20 |
+
# Install dependencies
|
| 21 |
+
RUN npm ci && \
|
| 22 |
+
npm cache clean --force
|
| 23 |
+
|
| 24 |
+
# Copy application source
|
| 25 |
+
COPY . .
|
| 26 |
+
|
| 27 |
+
# Build application for production
|
| 28 |
+
RUN npm run build
|
| 29 |
+
|
| 30 |
+
# ==========================================
|
| 31 |
+
# Stage 2: Runtime (Nginx with Built Assets)
|
| 32 |
+
# ==========================================
|
| 33 |
+
FROM nginx:1.25-alpine AS runtime
|
| 34 |
+
|
| 35 |
+
# Install curl for health checks
|
| 36 |
+
RUN apk add --no-cache curl
|
| 37 |
+
|
| 38 |
+
# Copy custom nginx configuration
|
| 39 |
+
COPY nginx.conf /etc/nginx/nginx.conf
|
| 40 |
+
|
| 41 |
+
# Copy built assets from builder stage
|
| 42 |
+
COPY --from=builder /app/dist /usr/share/nginx/html
|
| 43 |
+
|
| 44 |
+
# Set permissions for static files
|
| 45 |
+
RUN chmod -R 755 /usr/share/nginx/html
|
| 46 |
+
|
| 47 |
+
# Expose port
|
| 48 |
+
EXPOSE 80
|
| 49 |
+
|
| 50 |
+
# Health check
|
| 51 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
| 52 |
+
CMD curl -f http://localhost/ || exit 1
|
| 53 |
+
|
| 54 |
+
# Start nginx
|
| 55 |
+
CMD ["nginx", "-g", "daemon off;"]
|
frontend/nginx.conf
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
user nginx;
|
| 2 |
+
worker_processes auto;
|
| 3 |
+
error_log /var/log/nginx/error.log warn;
|
| 4 |
+
pid /var/run/nginx.pid;
|
| 5 |
+
|
| 6 |
+
events {
|
| 7 |
+
worker_connections 1024;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
http {
|
| 11 |
+
include /etc/nginx/mime.types;
|
| 12 |
+
default_type application/octet-stream;
|
| 13 |
+
|
| 14 |
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
| 15 |
+
'$status $body_bytes_sent "$http_referer" '
|
| 16 |
+
'"$http_user_agent" "$http_x_forwarded_for"';
|
| 17 |
+
|
| 18 |
+
access_log /var/log/nginx/access.log main;
|
| 19 |
+
|
| 20 |
+
sendfile on;
|
| 21 |
+
tcp_nopush on;
|
| 22 |
+
tcp_nodelay on;
|
| 23 |
+
keepalive_timeout 65;
|
| 24 |
+
types_hash_max_size 2048;
|
| 25 |
+
|
| 26 |
+
# Gzip compression
|
| 27 |
+
gzip on;
|
| 28 |
+
gzip_vary on;
|
| 29 |
+
gzip_proxied any;
|
| 30 |
+
gzip_comp_level 6;
|
| 31 |
+
gzip_types text/plain text/css text/xml text/javascript
|
| 32 |
+
application/json application/javascript application/xml+rss
|
| 33 |
+
application/rss+xml font/truetype font/opentype
|
| 34 |
+
application/vnd.ms-fontobject image/svg+xml;
|
| 35 |
+
|
| 36 |
+
server {
|
| 37 |
+
listen 80;
|
| 38 |
+
listen [::]:80;
|
| 39 |
+
server_name _;
|
| 40 |
+
|
| 41 |
+
root /usr/share/nginx/html;
|
| 42 |
+
index index.html;
|
| 43 |
+
|
| 44 |
+
# Security headers
|
| 45 |
+
add_header X-Frame-Options "SAMEORIGIN" always;
|
| 46 |
+
add_header X-Content-Type-Options "nosniff" always;
|
| 47 |
+
add_header X-XSS-Protection "1; mode=block" always;
|
| 48 |
+
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
| 49 |
+
|
| 50 |
+
# Vue.js SPA routing
|
| 51 |
+
location / {
|
| 52 |
+
try_files $uri $uri/ /index.html;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
# API proxy to backend
|
| 56 |
+
location /api/ {
|
| 57 |
+
proxy_pass http://backend:8000/;
|
| 58 |
+
proxy_http_version 1.1;
|
| 59 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 60 |
+
proxy_set_header Connection 'upgrade';
|
| 61 |
+
proxy_set_header Host $host;
|
| 62 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 63 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 64 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 65 |
+
proxy_cache_bypass $http_upgrade;
|
| 66 |
+
proxy_read_timeout 300s;
|
| 67 |
+
proxy_connect_timeout 75s;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
# WebSocket support for real-time communication
|
| 71 |
+
location /ws/ {
|
| 72 |
+
proxy_pass http://backend:8000/ws/;
|
| 73 |
+
proxy_http_version 1.1;
|
| 74 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 75 |
+
proxy_set_header Connection "upgrade";
|
| 76 |
+
proxy_set_header Host $host;
|
| 77 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 78 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 79 |
+
proxy_read_timeout 86400;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
# Cache static assets
|
| 83 |
+
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
|
| 84 |
+
expires 1y;
|
| 85 |
+
add_header Cache-Control "public, immutable";
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
# Disable access to hidden files
|
| 89 |
+
location ~ /\. {
|
| 90 |
+
deny all;
|
| 91 |
+
access_log off;
|
| 92 |
+
log_not_found off;
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
}
|
frontend/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
{
|
| 3 |
"name": "saap-dashboard",
|
| 4 |
"version": "1.0.0",
|
|
@@ -27,7 +26,10 @@
|
|
| 27 |
"socket.io-client": "^4.7.0",
|
| 28 |
"vue": "^3.4.0",
|
| 29 |
"vue-chartjs": "^5.3.0",
|
| 30 |
-
"vue-router": "^4.2.0"
|
|
|
|
|
|
|
|
|
|
| 31 |
},
|
| 32 |
"devDependencies": {
|
| 33 |
"@types/node": "^20.0.0",
|
|
@@ -35,11 +37,8 @@
|
|
| 35 |
"@vitest/coverage-v8": "^1.0.0",
|
| 36 |
"@vitest/ui": "^1.6.1",
|
| 37 |
"@vue/test-utils": "^2.4.6",
|
| 38 |
-
"autoprefixer": "^10.4.0",
|
| 39 |
"happy-dom": "^12.10.3",
|
| 40 |
"jsdom": "^23.2.0",
|
| 41 |
-
"postcss": "^8.4.0",
|
| 42 |
-
"tailwindcss": "^3.4.0",
|
| 43 |
"typescript": "^5.3.0",
|
| 44 |
"vite": "^5.0.0",
|
| 45 |
"vitest": "^1.6.1"
|
|
|
|
|
|
|
| 1 |
{
|
| 2 |
"name": "saap-dashboard",
|
| 3 |
"version": "1.0.0",
|
|
|
|
| 26 |
"socket.io-client": "^4.7.0",
|
| 27 |
"vue": "^3.4.0",
|
| 28 |
"vue-chartjs": "^5.3.0",
|
| 29 |
+
"vue-router": "^4.2.0",
|
| 30 |
+
"tailwindcss": "^3.4.0",
|
| 31 |
+
"postcss": "^8.4.0",
|
| 32 |
+
"autoprefixer": "^10.4.0"
|
| 33 |
},
|
| 34 |
"devDependencies": {
|
| 35 |
"@types/node": "^20.0.0",
|
|
|
|
| 37 |
"@vitest/coverage-v8": "^1.0.0",
|
| 38 |
"@vitest/ui": "^1.6.1",
|
| 39 |
"@vue/test-utils": "^2.4.6",
|
|
|
|
| 40 |
"happy-dom": "^12.10.3",
|
| 41 |
"jsdom": "^23.2.0",
|
|
|
|
|
|
|
| 42 |
"typescript": "^5.3.0",
|
| 43 |
"vite": "^5.0.0",
|
| 44 |
"vitest": "^1.6.1"
|
frontend/postcss.config.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = {
|
| 2 |
+
plugins: {
|
| 3 |
+
tailwindcss: {},
|
| 4 |
+
autoprefixer: {},
|
| 5 |
+
},
|
| 6 |
+
}
|
frontend/src/router/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
*/
|
| 5 |
|
| 6 |
import { createRouter, createWebHistory } from 'vue-router'
|
| 7 |
-
import
|
| 8 |
import DashboardSimple from '@/views/DashboardSimple.vue'
|
| 9 |
import AgentDetails from '@/views/AgentDetails.vue'
|
| 10 |
import Settings from '@/views/Settings.vue'
|
|
@@ -16,7 +16,7 @@ const router = createRouter({
|
|
| 16 |
{
|
| 17 |
path: '/',
|
| 18 |
name: 'Dashboard',
|
| 19 |
-
component:
|
| 20 |
meta: {
|
| 21 |
title: 'SAAP Dashboard',
|
| 22 |
requiresAuth: false
|
|
@@ -84,4 +84,4 @@ router.afterEach((to, from) => {
|
|
| 84 |
console.log(`🧭 Navigated from ${from.path} to ${to.path}`)
|
| 85 |
})
|
| 86 |
|
| 87 |
-
export default router
|
|
|
|
| 4 |
*/
|
| 5 |
|
| 6 |
import { createRouter, createWebHistory } from 'vue-router'
|
| 7 |
+
import SaapDashboard from '@/components/SaapDashboard.vue'
|
| 8 |
import DashboardSimple from '@/views/DashboardSimple.vue'
|
| 9 |
import AgentDetails from '@/views/AgentDetails.vue'
|
| 10 |
import Settings from '@/views/Settings.vue'
|
|
|
|
| 16 |
{
|
| 17 |
path: '/',
|
| 18 |
name: 'Dashboard',
|
| 19 |
+
component: SaapDashboard, // ✅ FIXED: Use SaapDashboard with beautiful card layout
|
| 20 |
meta: {
|
| 21 |
title: 'SAAP Dashboard',
|
| 22 |
requiresAuth: false
|
|
|
|
| 84 |
console.log(`🧭 Navigated from ${from.path} to ${to.path}`)
|
| 85 |
})
|
| 86 |
|
| 87 |
+
export default router
|