4.1 KiB
4.1 KiB
Deployment Runbook — ERP Nutzfahrzeuge
Prerequisites
- PostgreSQL — running and accessible (managed or self-hosted)
- Redis (optional) — if async features (OCR, retouch, mobile.de push) are needed
- Node.js — for frontend build (if building at deploy time)
- Python 3.11+ — for backend runtime
- Coolify (or Docker) — for containerized deployment
Pre-Deployment Steps
1. Verify Environment Variables
Ensure all required variables are configured in Coolify or .env:
# Required
DATABASE_URL=postgresql+asyncpg://<user>:<password>@<host>:5432/<dbname>
JWT_SECRET=<generate with: openssl rand -hex 32>
# Important
APP_ENV=production
CORS_ORIGINS=https://your-frontend-domain.com
UPLOAD_DIR=/app/uploads # persistent volume
# Optional (feature-dependent)
REDIS_URL=redis://<host>:6379/0
OPENROUTER_API_KEY=<key>
MOBILE_DE_API_KEY=<key>
MOBILE_DE_SELLER_ID=<id>
2. Build Frontend
cd frontend
npm ci
npm run build
Build artifacts are output to frontend/.next/.
3. Verify Backend Dependencies
cd backend
/opt/venv/bin/pip install -r requirements.txt
/opt/venv/bin/python -c "from app.main import app; print('Import OK')"
4. Database Migration (if applicable)
cd backend
/opt/venv/bin/python -m alembic upgrade head # if Alembic is configured
# Or ensure tables are created via app startup
Deployment Steps (Coolify)
Step 1: Create Resource
- In Coolify, create a new resource (Docker Compose or Dockerfile-based)
- Configure the source repository
- Set the build/pack type
Step 2: Configure Environment
- Navigate to resource → Environment Variables
- Add all variables from
deploy/env.md - Ensure
JWT_SECRETis a secure random value - Set
APP_ENV=production
Step 3: Configure Health Check
- Set health check path to
/api/v1/health - Set port to
8000 - See
deploy/healthcheck.mdfor full configuration
Step 4: Configure Persistent Storage
- Mount a persistent volume for
UPLOAD_DIR(e.g.,/app/uploads) - Ensure database volume is persistent
Step 5: Deploy
- Click Deploy in Coolify
- Wait for build and startup to complete
- Verify health check passes (green status)
- Test endpoints:
GET /api/v1/health→ 200{"status":"ok"}GET /→ 200 app metadataGET /openapi.json→ 200 OpenAPI schema
Step 6: Post-Deployment Verification
- Verify frontend is accessible at the configured domain
- Test login flow:
POST /api/v1/auth/loginwith valid credentials - Verify CORS headers are present for frontend origin
- Check logs for any errors:
docker logs <container_name> --tail 50
Deployment Steps (Docker Compose)
docker-compose.yml (template)
version: '3.8'
services:
backend:
build: ./backend
ports:
- "8000:8000"
environment:
- DATABASE_URL=postgresql+asyncpg://user:pass@db:5432/erp
- JWT_SECRET=${JWT_SECRET}
- APP_ENV=production
- CORS_ORIGINS=https://your-domain.com
- UPLOAD_DIR=/app/uploads
- REDIS_URL=redis://redis:6379/0
volumes:
- uploads:/app/uploads
depends_on:
- db
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
db:
image: postgres:16-alpine
environment:
- POSTGRES_USER=erp_user
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=erp
volumes:
- pgdata:/var/lib/postgresql/data
redis:
image: redis:7-alpine
volumes:
- redisdata:/data
frontend:
build: ./frontend
ports:
- "3000:3000"
depends_on:
- backend
volumes:
uploads:
pgdata:
redisdata:
Start Command (standalone)
cd backend && /opt/venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
For production with workers:
cd backend && /opt/venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4
Rollback
See deploy/rollback.md for rollback procedure.