2025-10-24 13:05:04 +02:00
|
|
|
# Tiltfile for Bakery IA - Secure Local Development
|
|
|
|
|
# Includes TLS encryption, strong passwords, PVCs, and audit logging
|
2025-10-01 18:58:30 +02:00
|
|
|
|
2025-10-24 13:05:04 +02:00
|
|
|
# =============================================================================
|
|
|
|
|
# SECURITY SETUP
|
|
|
|
|
# =============================================================================
|
|
|
|
|
print("""
|
|
|
|
|
======================================
|
|
|
|
|
🔐 Bakery IA Secure Development Mode
|
|
|
|
|
======================================
|
|
|
|
|
|
|
|
|
|
Security Features:
|
|
|
|
|
✅ TLS encryption for PostgreSQL and Redis
|
|
|
|
|
✅ Strong 32-character passwords
|
|
|
|
|
✅ PersistentVolumeClaims (no data loss)
|
|
|
|
|
✅ pgcrypto extension for encryption
|
|
|
|
|
✅ PostgreSQL audit logging
|
|
|
|
|
|
|
|
|
|
Applying security configurations...
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# Apply security configurations before loading main manifests
|
|
|
|
|
local_resource('security-setup',
|
|
|
|
|
cmd='''
|
|
|
|
|
echo "📦 Applying security secrets and configurations..."
|
|
|
|
|
kubectl apply -f infrastructure/kubernetes/base/secrets.yaml
|
|
|
|
|
kubectl apply -f infrastructure/kubernetes/base/secrets/postgres-tls-secret.yaml
|
|
|
|
|
kubectl apply -f infrastructure/kubernetes/base/secrets/redis-tls-secret.yaml
|
|
|
|
|
kubectl apply -f infrastructure/kubernetes/base/configs/postgres-init-config.yaml
|
|
|
|
|
kubectl apply -f infrastructure/kubernetes/base/configmaps/postgres-logging-config.yaml
|
|
|
|
|
echo "✅ Security configurations applied"
|
|
|
|
|
''',
|
|
|
|
|
labels=['security'],
|
|
|
|
|
auto_init=True)
|
|
|
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
|
# LOAD KUBERNETES MANIFESTS
|
|
|
|
|
# =============================================================================
|
2025-10-01 18:58:30 +02:00
|
|
|
# Load Kubernetes manifests using Kustomize
|
|
|
|
|
k8s_yaml(kustomize('infrastructure/kubernetes/overlays/dev'))
|
|
|
|
|
|
|
|
|
|
# No registry needed for local development - images are built locally
|
|
|
|
|
|
|
|
|
|
# Common live update configuration for Python FastAPI services
|
|
|
|
|
def python_live_update(service_name, service_path):
|
|
|
|
|
return sync(service_path, '/app')
|
|
|
|
|
|
|
|
|
|
# =============================================================================
|
2025-11-07 21:01:51 +00:00
|
|
|
# FRONTEND (React + Vite)
|
2025-10-01 18:58:30 +02:00
|
|
|
# =============================================================================
|
2025-11-27 15:52:40 +01:00
|
|
|
# Multi-stage build with optimized memory settings for large Vite builds
|
|
|
|
|
# Set FRONTEND_DEBUG=true environment variable to build with development mode (no minification)
|
|
|
|
|
# for easier debugging of React errors
|
|
|
|
|
|
|
|
|
|
# Check for FRONTEND_DEBUG environment variable (Starlark uses os.getenv)
|
|
|
|
|
frontend_debug_env = os.getenv('FRONTEND_DEBUG', 'false')
|
|
|
|
|
frontend_debug = frontend_debug_env.lower() == 'true'
|
|
|
|
|
|
|
|
|
|
# Log the build mode
|
|
|
|
|
if frontend_debug:
|
|
|
|
|
print("""
|
|
|
|
|
🐛 FRONTEND DEBUG MODE ENABLED
|
|
|
|
|
Building frontend with NO minification for easier debugging.
|
|
|
|
|
Full React error messages will be displayed.
|
|
|
|
|
To disable: unset FRONTEND_DEBUG or set FRONTEND_DEBUG=false
|
|
|
|
|
""")
|
|
|
|
|
else:
|
|
|
|
|
print("""
|
|
|
|
|
📦 FRONTEND PRODUCTION MODE
|
|
|
|
|
Building frontend with minification for optimized performance.
|
|
|
|
|
To enable debug mode: export FRONTEND_DEBUG=true
|
|
|
|
|
""")
|
|
|
|
|
|
2025-10-01 18:58:30 +02:00
|
|
|
docker_build(
|
|
|
|
|
'bakery/dashboard',
|
|
|
|
|
context='./frontend',
|
2025-11-27 15:52:40 +01:00
|
|
|
dockerfile='./frontend/Dockerfile.kubernetes.debug' if frontend_debug else './frontend/Dockerfile.kubernetes',
|
|
|
|
|
# Remove target to build the full image, including the build stage
|
2025-10-01 18:58:30 +02:00
|
|
|
live_update=[
|
|
|
|
|
sync('./frontend/src', '/app/src'),
|
|
|
|
|
sync('./frontend/public', '/app/public'),
|
2025-11-15 21:21:06 +01:00
|
|
|
],
|
2025-11-27 15:52:40 +01:00
|
|
|
# Increase Node.js memory for build stage
|
|
|
|
|
build_args={
|
|
|
|
|
'NODE_OPTIONS': '--max-old-space-size=8192'
|
|
|
|
|
},
|
2025-11-15 21:21:06 +01:00
|
|
|
# Ignore test artifacts and reports
|
|
|
|
|
ignore=[
|
|
|
|
|
'playwright-report/**',
|
|
|
|
|
'test-results/**',
|
|
|
|
|
'node_modules/**',
|
|
|
|
|
'.DS_Store'
|
2025-10-01 18:58:30 +02:00
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
|
# GATEWAY
|
|
|
|
|
# =============================================================================
|
|
|
|
|
docker_build(
|
|
|
|
|
'bakery/gateway',
|
|
|
|
|
context='.',
|
|
|
|
|
dockerfile='./gateway/Dockerfile',
|
|
|
|
|
live_update=[
|
2025-10-07 07:15:07 +02:00
|
|
|
# Fall back to full rebuild if Dockerfile or requirements change
|
|
|
|
|
fall_back_on(['./gateway/Dockerfile', './gateway/requirements.txt']),
|
|
|
|
|
|
2025-10-01 18:58:30 +02:00
|
|
|
# Sync Python code changes
|
|
|
|
|
sync('./gateway', '/app'),
|
|
|
|
|
sync('./shared', '/app/shared'),
|
|
|
|
|
|
|
|
|
|
# Restart on Python file changes
|
|
|
|
|
run('kill -HUP 1', trigger=['./gateway/**/*.py', './shared/**/*.py']),
|
2025-10-07 07:15:07 +02:00
|
|
|
],
|
|
|
|
|
# Ignore common patterns that don't require rebuilds
|
|
|
|
|
ignore=[
|
|
|
|
|
'.git',
|
|
|
|
|
'**/__pycache__',
|
|
|
|
|
'**/*.pyc',
|
|
|
|
|
'**/.pytest_cache',
|
|
|
|
|
'**/node_modules',
|
|
|
|
|
'**/.DS_Store'
|
2025-10-01 18:58:30 +02:00
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
|
# MICROSERVICES - Python FastAPI Services
|
|
|
|
|
# =============================================================================
|
|
|
|
|
|
|
|
|
|
# Helper function to create docker build with live updates for Python services
|
|
|
|
|
def build_python_service(service_name, service_path):
|
|
|
|
|
docker_build(
|
|
|
|
|
'bakery/' + service_name,
|
|
|
|
|
context='.',
|
|
|
|
|
dockerfile='./services/' + service_path + '/Dockerfile',
|
|
|
|
|
live_update=[
|
2025-10-07 07:15:07 +02:00
|
|
|
# Fall back to full image build if Dockerfile or requirements change
|
|
|
|
|
fall_back_on(['./services/' + service_path + '/Dockerfile',
|
|
|
|
|
'./services/' + service_path + '/requirements.txt']),
|
|
|
|
|
|
2025-10-01 18:58:30 +02:00
|
|
|
# Sync service code
|
|
|
|
|
sync('./services/' + service_path, '/app'),
|
|
|
|
|
|
2025-10-24 13:05:04 +02:00
|
|
|
# Sync shared libraries (includes updated TLS connection code)
|
2025-10-01 18:58:30 +02:00
|
|
|
sync('./shared', '/app/shared'),
|
|
|
|
|
|
|
|
|
|
# Sync scripts
|
|
|
|
|
sync('./scripts', '/app/scripts'),
|
|
|
|
|
|
|
|
|
|
# Install new dependencies if requirements.txt changes
|
|
|
|
|
run('pip install --no-cache-dir -r requirements.txt',
|
|
|
|
|
trigger=['./services/' + service_path + '/requirements.txt']),
|
|
|
|
|
|
|
|
|
|
# Restart uvicorn on Python file changes (HUP signal triggers graceful reload)
|
|
|
|
|
run('kill -HUP 1',
|
|
|
|
|
trigger=[
|
|
|
|
|
'./services/' + service_path + '/**/*.py',
|
|
|
|
|
'./shared/**/*.py'
|
|
|
|
|
]),
|
2025-10-07 07:15:07 +02:00
|
|
|
],
|
|
|
|
|
# Ignore common patterns that don't require rebuilds
|
|
|
|
|
ignore=[
|
|
|
|
|
'.git',
|
|
|
|
|
'**/__pycache__',
|
|
|
|
|
'**/*.pyc',
|
|
|
|
|
'**/.pytest_cache',
|
|
|
|
|
'**/node_modules',
|
|
|
|
|
'**/.DS_Store'
|
2025-10-01 18:58:30 +02:00
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Build all microservices
|
|
|
|
|
build_python_service('auth-service', 'auth')
|
|
|
|
|
build_python_service('tenant-service', 'tenant')
|
|
|
|
|
build_python_service('training-service', 'training')
|
|
|
|
|
build_python_service('forecasting-service', 'forecasting')
|
|
|
|
|
build_python_service('sales-service', 'sales')
|
|
|
|
|
build_python_service('external-service', 'external')
|
|
|
|
|
build_python_service('notification-service', 'notification')
|
|
|
|
|
build_python_service('inventory-service', 'inventory')
|
|
|
|
|
build_python_service('recipes-service', 'recipes')
|
|
|
|
|
build_python_service('suppliers-service', 'suppliers')
|
|
|
|
|
build_python_service('pos-service', 'pos')
|
|
|
|
|
build_python_service('orders-service', 'orders')
|
|
|
|
|
build_python_service('production-service', 'production')
|
2025-10-30 21:08:07 +01:00
|
|
|
build_python_service('procurement-service', 'procurement') # NEW: Sprint 3
|
|
|
|
|
build_python_service('orchestrator-service', 'orchestrator') # NEW: Sprint 2
|
2025-11-05 13:34:56 +01:00
|
|
|
build_python_service('ai-insights-service', 'ai_insights') # NEW: AI Insights Platform
|
2025-11-27 15:52:40 +01:00
|
|
|
build_python_service('alert-processor', 'alert_processor') # Unified Alert Service with enrichment
|
2025-10-03 14:09:34 +02:00
|
|
|
build_python_service('demo-session-service', 'demo_session')
|
2025-11-30 09:12:40 +01:00
|
|
|
build_python_service('distribution-service', 'distribution') # NEW: Distribution Service for Enterprise Tier
|
2025-10-01 18:58:30 +02:00
|
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
|
# RESOURCE DEPENDENCIES & ORDERING
|
|
|
|
|
# =============================================================================
|
|
|
|
|
|
2025-10-24 13:05:04 +02:00
|
|
|
# Security setup must complete before databases start
|
|
|
|
|
k8s_resource('auth-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('tenant-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('training-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('forecasting-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('sales-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('external-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('notification-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('inventory-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('recipes-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('suppliers-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('pos-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('orders-db', resource_deps=['security-setup'], labels=['databases'])
|
|
|
|
|
k8s_resource('production-db', resource_deps=['security-setup'], labels=['databases'])
|
2025-10-30 21:08:07 +01:00
|
|
|
k8s_resource('procurement-db', resource_deps=['security-setup'], labels=['databases']) # NEW: Sprint 3
|
|
|
|
|
k8s_resource('orchestrator-db', resource_deps=['security-setup'], labels=['databases']) # NEW: Sprint 2
|
2025-11-05 13:34:56 +01:00
|
|
|
k8s_resource('ai-insights-db', resource_deps=['security-setup'], labels=['databases']) # NEW: AI Insights Platform
|
2025-11-27 15:52:40 +01:00
|
|
|
k8s_resource('alert-processor-db', resource_deps=['security-setup'], labels=['databases']) # Unified Alert Service
|
2025-10-24 13:05:04 +02:00
|
|
|
k8s_resource('demo-session-db', resource_deps=['security-setup'], labels=['databases'])
|
2025-11-30 09:12:40 +01:00
|
|
|
k8s_resource('distribution-db', resource_deps=['security-setup'], labels=['databases']) # NEW: Distribution Service
|
2025-10-24 13:05:04 +02:00
|
|
|
|
|
|
|
|
k8s_resource('redis', resource_deps=['security-setup'], labels=['infrastructure'])
|
2025-10-01 18:58:30 +02:00
|
|
|
k8s_resource('rabbitmq', labels=['infrastructure'])
|
|
|
|
|
|
2025-10-24 13:05:04 +02:00
|
|
|
# Verify TLS certificates are mounted correctly
|
|
|
|
|
local_resource('verify-tls',
|
|
|
|
|
cmd='''
|
|
|
|
|
echo "🔍 Verifying TLS configuration..."
|
|
|
|
|
sleep 5 # Wait for pods to be ready
|
|
|
|
|
|
|
|
|
|
# Check if auth-db pod exists and has TLS certs
|
|
|
|
|
AUTH_POD=$(kubectl get pods -n bakery-ia -l app.kubernetes.io/name=auth-db -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || echo "")
|
|
|
|
|
|
|
|
|
|
if [ -n "$AUTH_POD" ]; then
|
|
|
|
|
echo " Checking PostgreSQL TLS certificates..."
|
|
|
|
|
kubectl exec -n bakery-ia "$AUTH_POD" -- ls -la /tls/ 2>/dev/null && \
|
|
|
|
|
echo " ✅ PostgreSQL TLS certificates mounted" || \
|
|
|
|
|
echo " ⚠️ PostgreSQL TLS certificates not found (pods may still be starting)"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check if redis pod exists and has TLS certs
|
|
|
|
|
REDIS_POD=$(kubectl get pods -n bakery-ia -l app.kubernetes.io/name=redis -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || echo "")
|
|
|
|
|
|
|
|
|
|
if [ -n "$REDIS_POD" ]; then
|
|
|
|
|
echo " Checking Redis TLS certificates..."
|
|
|
|
|
kubectl exec -n bakery-ia "$REDIS_POD" -- ls -la /tls/ 2>/dev/null && \
|
|
|
|
|
echo " ✅ Redis TLS certificates mounted" || \
|
|
|
|
|
echo " ⚠️ Redis TLS certificates not found (pods may still be starting)"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "✅ TLS verification complete"
|
|
|
|
|
''',
|
|
|
|
|
resource_deps=['auth-db', 'redis'],
|
|
|
|
|
auto_init=True,
|
|
|
|
|
trigger_mode=TRIGGER_MODE_MANUAL,
|
|
|
|
|
labels=['security'])
|
|
|
|
|
|
|
|
|
|
# Verify PVCs are bound
|
|
|
|
|
local_resource('verify-pvcs',
|
|
|
|
|
cmd='''
|
|
|
|
|
echo "🔍 Verifying PersistentVolumeClaims..."
|
|
|
|
|
kubectl get pvc -n bakery-ia | grep -E "NAME|db-pvc" || echo " ⚠️ PVCs not yet bound"
|
|
|
|
|
PVC_COUNT=$(kubectl get pvc -n bakery-ia -o json | jq '.items | length')
|
|
|
|
|
echo " Found $PVC_COUNT PVCs"
|
|
|
|
|
echo "✅ PVC verification complete"
|
|
|
|
|
''',
|
|
|
|
|
resource_deps=['auth-db'],
|
|
|
|
|
auto_init=True,
|
|
|
|
|
trigger_mode=TRIGGER_MODE_MANUAL,
|
|
|
|
|
labels=['security'])
|
|
|
|
|
|
2025-10-15 16:12:49 +02:00
|
|
|
# Nominatim geocoding service (excluded in dev via kustomize patches)
|
|
|
|
|
# Uncomment these if you want to test nominatim locally
|
|
|
|
|
# k8s_resource('nominatim',
|
|
|
|
|
# resource_deps=['nominatim-init'],
|
|
|
|
|
# labels=['infrastructure'])
|
|
|
|
|
# k8s_resource('nominatim-init',
|
|
|
|
|
# labels=['data-init'])
|
|
|
|
|
|
|
|
|
|
# Monitoring stack
|
|
|
|
|
#k8s_resource('prometheus',
|
|
|
|
|
# labels=['monitoring'])
|
|
|
|
|
|
|
|
|
|
#k8s_resource('grafana',
|
|
|
|
|
# resource_deps=['prometheus'],
|
|
|
|
|
# labels=['monitoring'])
|
|
|
|
|
|
|
|
|
|
#k8s_resource('jaeger',
|
|
|
|
|
# labels=['monitoring'])
|
|
|
|
|
|
2025-10-01 18:58:30 +02:00
|
|
|
# Migration jobs depend on databases
|
|
|
|
|
k8s_resource('auth-migration', resource_deps=['auth-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('tenant-migration', resource_deps=['tenant-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('training-migration', resource_deps=['training-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('forecasting-migration', resource_deps=['forecasting-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('sales-migration', resource_deps=['sales-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('external-migration', resource_deps=['external-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('notification-migration', resource_deps=['notification-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('inventory-migration', resource_deps=['inventory-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('recipes-migration', resource_deps=['recipes-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('suppliers-migration', resource_deps=['suppliers-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('pos-migration', resource_deps=['pos-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('orders-migration', resource_deps=['orders-db'], labels=['migrations'])
|
|
|
|
|
k8s_resource('production-migration', resource_deps=['production-db'], labels=['migrations'])
|
2025-10-30 21:08:07 +01:00
|
|
|
k8s_resource('procurement-migration', resource_deps=['procurement-db'], labels=['migrations']) # NEW: Sprint 3
|
|
|
|
|
k8s_resource('orchestrator-migration', resource_deps=['orchestrator-db'], labels=['migrations']) # NEW: Sprint 2
|
2025-11-05 13:34:56 +01:00
|
|
|
k8s_resource('ai-insights-migration', resource_deps=['ai-insights-db'], labels=['migrations']) # NEW: AI Insights Platform
|
2025-10-01 18:58:30 +02:00
|
|
|
k8s_resource('alert-processor-migration', resource_deps=['alert-processor-db'], labels=['migrations'])
|
2025-10-03 14:09:34 +02:00
|
|
|
k8s_resource('demo-session-migration', resource_deps=['demo-session-db'], labels=['migrations'])
|
2025-11-30 09:12:40 +01:00
|
|
|
k8s_resource('distribution-migration', resource_deps=['distribution-db'], labels=['migrations']) # NEW: Distribution Service
|
2025-10-01 18:58:30 +02:00
|
|
|
|
2025-10-03 14:09:34 +02:00
|
|
|
# =============================================================================
|
|
|
|
|
# DEMO INITIALIZATION JOBS
|
|
|
|
|
# =============================================================================
|
2025-10-24 13:05:04 +02:00
|
|
|
# Demo seed jobs run in strict order to ensure data consistency across services
|
2025-10-17 07:31:14 +02:00
|
|
|
|
|
|
|
|
# Weight 5: Seed users (auth service) - includes staff users
|
2025-10-03 14:09:34 +02:00
|
|
|
k8s_resource('demo-seed-users',
|
|
|
|
|
resource_deps=['auth-migration'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-17 07:31:14 +02:00
|
|
|
# Weight 10: Seed tenants (tenant service)
|
2025-10-03 14:09:34 +02:00
|
|
|
k8s_resource('demo-seed-tenants',
|
|
|
|
|
resource_deps=['tenant-migration', 'demo-seed-users'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-17 07:31:14 +02:00
|
|
|
# Weight 15: Seed tenant members (links staff users to tenants)
|
|
|
|
|
k8s_resource('demo-seed-tenant-members',
|
|
|
|
|
resource_deps=['tenant-migration', 'demo-seed-tenants', 'demo-seed-users'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
|
|
|
|
# Weight 10: Seed subscriptions (creates enterprise subscriptions for demo tenants)
|
2025-10-12 18:47:33 +02:00
|
|
|
k8s_resource('demo-seed-subscriptions',
|
|
|
|
|
resource_deps=['tenant-migration', 'demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-18 16:03:23 +02:00
|
|
|
# Seed pilot coupon (runs after tenant migration)
|
|
|
|
|
k8s_resource('tenant-seed-pilot-coupon',
|
|
|
|
|
resource_deps=['tenant-migration'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-17 07:31:14 +02:00
|
|
|
# Weight 15: Seed inventory - CRITICAL: All other seeds depend on this
|
2025-10-03 14:09:34 +02:00
|
|
|
k8s_resource('demo-seed-inventory',
|
|
|
|
|
resource_deps=['inventory-migration', 'demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-17 07:31:14 +02:00
|
|
|
# Weight 15: Seed recipes (uses ingredient IDs from inventory)
|
2025-10-12 18:47:33 +02:00
|
|
|
k8s_resource('demo-seed-recipes',
|
|
|
|
|
resource_deps=['recipes-migration', 'demo-seed-inventory'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-17 07:31:14 +02:00
|
|
|
# Weight 15: Seed suppliers (uses ingredient IDs for price lists)
|
2025-10-12 18:47:33 +02:00
|
|
|
k8s_resource('demo-seed-suppliers',
|
|
|
|
|
resource_deps=['suppliers-migration', 'demo-seed-inventory'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-17 07:31:14 +02:00
|
|
|
# Weight 15: Seed sales (uses finished product IDs from inventory)
|
2025-10-12 18:47:33 +02:00
|
|
|
k8s_resource('demo-seed-sales',
|
|
|
|
|
resource_deps=['sales-migration', 'demo-seed-inventory'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-17 07:31:14 +02:00
|
|
|
# Weight 15: Seed AI models (creates training/forecasting model records)
|
2025-10-03 14:09:34 +02:00
|
|
|
k8s_resource('demo-seed-ai-models',
|
|
|
|
|
resource_deps=['training-migration', 'demo-seed-inventory'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-17 07:31:14 +02:00
|
|
|
# Weight 20: Seed stock batches (inventory service)
|
|
|
|
|
k8s_resource('demo-seed-stock',
|
|
|
|
|
resource_deps=['inventory-migration', 'demo-seed-inventory'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
|
|
|
|
# Weight 22: Seed quality check templates (production service)
|
|
|
|
|
k8s_resource('demo-seed-quality-templates',
|
|
|
|
|
resource_deps=['production-migration', 'demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
|
|
|
|
# Weight 25: Seed customers (orders service)
|
|
|
|
|
k8s_resource('demo-seed-customers',
|
|
|
|
|
resource_deps=['orders-migration', 'demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
|
|
|
|
# Weight 25: Seed equipment (production service)
|
|
|
|
|
k8s_resource('demo-seed-equipment',
|
|
|
|
|
resource_deps=['production-migration', 'demo-seed-tenants', 'demo-seed-quality-templates'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
|
|
|
|
# Weight 30: Seed production batches (production service)
|
|
|
|
|
k8s_resource('demo-seed-production-batches',
|
|
|
|
|
resource_deps=['production-migration', 'demo-seed-recipes', 'demo-seed-equipment'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
|
|
|
|
# Weight 30: Seed orders with line items (orders service)
|
|
|
|
|
k8s_resource('demo-seed-orders',
|
|
|
|
|
resource_deps=['orders-migration', 'demo-seed-customers'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-30 21:08:07 +01:00
|
|
|
# Weight 35: Seed procurement plans (procurement service)
|
|
|
|
|
k8s_resource('demo-seed-procurement-plans',
|
|
|
|
|
resource_deps=['procurement-migration', 'demo-seed-tenants'],
|
2025-10-17 07:31:14 +02:00
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
|
|
|
|
# Weight 40: Seed demand forecasts (forecasting service)
|
|
|
|
|
k8s_resource('demo-seed-forecasts',
|
|
|
|
|
resource_deps=['forecasting-migration', 'demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-30 21:08:07 +01:00
|
|
|
# Weight 45: Seed orchestration runs (orchestrator service)
|
|
|
|
|
k8s_resource('demo-seed-orchestration-runs',
|
|
|
|
|
resource_deps=['orchestrator-migration', 'demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-11-27 15:52:40 +01:00
|
|
|
# Weight 28: Seed alerts (alert processor service) - after orchestration runs as alerts reference recent data
|
|
|
|
|
k8s_resource('demo-seed-alerts',
|
|
|
|
|
resource_deps=['alert-processor-migration', 'demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-10-30 21:08:07 +01:00
|
|
|
k8s_resource('demo-seed-pos-configs',
|
|
|
|
|
resource_deps=['demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('demo-seed-purchase-orders',
|
|
|
|
|
resource_deps=['procurement-migration', 'demo-seed-tenants'],
|
|
|
|
|
labels=['demo-init'])
|
|
|
|
|
|
2025-11-30 09:12:40 +01:00
|
|
|
# Phase 2: Child retail seed jobs (for enterprise demo)
|
|
|
|
|
k8s_resource('demo-seed-inventory-retail',
|
|
|
|
|
resource_deps=['inventory-migration', 'demo-seed-inventory'],
|
|
|
|
|
labels=['demo-init', 'retail'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('demo-seed-stock-retail',
|
|
|
|
|
resource_deps=['inventory-migration', 'demo-seed-inventory-retail'],
|
|
|
|
|
labels=['demo-init', 'retail'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('demo-seed-sales-retail',
|
|
|
|
|
resource_deps=['sales-migration', 'demo-seed-stock-retail'],
|
|
|
|
|
labels=['demo-init', 'retail'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('demo-seed-customers-retail',
|
|
|
|
|
resource_deps=['orders-migration', 'demo-seed-sales-retail'],
|
|
|
|
|
labels=['demo-init', 'retail'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('demo-seed-pos-retail',
|
|
|
|
|
resource_deps=['pos-migration', 'demo-seed-customers-retail'],
|
|
|
|
|
labels=['demo-init', 'retail'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('demo-seed-forecasts-retail',
|
|
|
|
|
resource_deps=['forecasting-migration', 'demo-seed-pos-retail'],
|
|
|
|
|
labels=['demo-init', 'retail'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('demo-seed-alerts-retail',
|
|
|
|
|
resource_deps=['alert-processor-migration', 'demo-seed-forecasts-retail'],
|
|
|
|
|
labels=['demo-init', 'retail'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('demo-seed-distribution-history',
|
|
|
|
|
resource_deps=['distribution-migration', 'demo-seed-alerts-retail'],
|
|
|
|
|
labels=['demo-init', 'enterprise'])
|
|
|
|
|
|
2025-10-30 21:08:07 +01:00
|
|
|
|
2025-10-03 14:09:34 +02:00
|
|
|
# =============================================================================
|
|
|
|
|
# SERVICES
|
|
|
|
|
# =============================================================================
|
2025-10-01 18:58:30 +02:00
|
|
|
# Services depend on their databases AND migrations
|
2025-10-03 14:09:34 +02:00
|
|
|
|
2025-10-01 18:58:30 +02:00
|
|
|
k8s_resource('auth-service',
|
|
|
|
|
resource_deps=['auth-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('tenant-service',
|
|
|
|
|
resource_deps=['tenant-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('training-service',
|
|
|
|
|
resource_deps=['training-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('forecasting-service',
|
|
|
|
|
resource_deps=['forecasting-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('sales-service',
|
|
|
|
|
resource_deps=['sales-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('external-service',
|
2025-10-09 14:11:02 +02:00
|
|
|
resource_deps=['external-migration', 'external-data-init', 'redis'],
|
2025-10-01 18:58:30 +02:00
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('notification-service',
|
|
|
|
|
resource_deps=['notification-migration', 'redis', 'rabbitmq'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('inventory-service',
|
|
|
|
|
resource_deps=['inventory-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('recipes-service',
|
|
|
|
|
resource_deps=['recipes-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('suppliers-service',
|
|
|
|
|
resource_deps=['suppliers-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('pos-service',
|
|
|
|
|
resource_deps=['pos-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('orders-service',
|
|
|
|
|
resource_deps=['orders-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('production-service',
|
|
|
|
|
resource_deps=['production-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
2025-10-30 21:08:07 +01:00
|
|
|
k8s_resource('procurement-service',
|
|
|
|
|
resource_deps=['procurement-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('orchestrator-service',
|
|
|
|
|
resource_deps=['orchestrator-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
2025-11-05 13:34:56 +01:00
|
|
|
k8s_resource('ai-insights-service',
|
|
|
|
|
resource_deps=['ai-insights-migration', 'redis', 'forecasting-service', 'production-service', 'procurement-service'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
2025-10-01 18:58:30 +02:00
|
|
|
k8s_resource('alert-processor-service',
|
|
|
|
|
resource_deps=['alert-processor-migration', 'redis', 'rabbitmq'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
2025-10-30 21:08:07 +01:00
|
|
|
k8s_resource('alert-processor-api',
|
|
|
|
|
resource_deps=['alert-processor-migration'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
2025-10-03 14:09:34 +02:00
|
|
|
k8s_resource('demo-session-service',
|
|
|
|
|
resource_deps=['demo-session-migration', 'redis'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
2025-11-30 16:29:38 +01:00
|
|
|
k8s_resource('demo-cleanup-worker',
|
|
|
|
|
resource_deps=['demo-session-service', 'redis'],
|
|
|
|
|
labels=['services', 'workers'])
|
|
|
|
|
|
2025-11-30 09:12:40 +01:00
|
|
|
k8s_resource('distribution-service',
|
|
|
|
|
resource_deps=['distribution-migration', 'redis', 'rabbitmq'],
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
2025-10-30 21:08:07 +01:00
|
|
|
k8s_resource('nominatim',
|
|
|
|
|
labels=['services'])
|
|
|
|
|
|
2025-10-03 14:09:34 +02:00
|
|
|
# Apply environment variable patch to demo-session-service with the inventory image
|
|
|
|
|
local_resource('patch-demo-session-env',
|
2025-10-12 18:47:33 +02:00
|
|
|
cmd='''
|
|
|
|
|
# Wait a moment for deployments to stabilize
|
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
|
|
# Get current inventory-service image tag
|
|
|
|
|
INVENTORY_IMAGE=$(kubectl get deployment inventory-service -n bakery-ia -o jsonpath="{.spec.template.spec.containers[0].image}" 2>/dev/null || echo "bakery/inventory-service:latest")
|
|
|
|
|
|
|
|
|
|
# Update demo-session-service environment variable
|
|
|
|
|
kubectl set env deployment/demo-session-service -n bakery-ia CLONE_JOB_IMAGE=$INVENTORY_IMAGE
|
|
|
|
|
|
|
|
|
|
echo "✅ Set CLONE_JOB_IMAGE to: $INVENTORY_IMAGE"
|
|
|
|
|
''',
|
2025-10-24 13:05:04 +02:00
|
|
|
resource_deps=['demo-session-service', 'inventory-service'],
|
|
|
|
|
auto_init=True,
|
2025-10-03 14:09:34 +02:00
|
|
|
labels=['config'])
|
|
|
|
|
|
2025-10-09 14:11:02 +02:00
|
|
|
# =============================================================================
|
|
|
|
|
# DATA INITIALIZATION JOBS (External Service v2.0)
|
|
|
|
|
# =============================================================================
|
|
|
|
|
k8s_resource('external-data-init',
|
|
|
|
|
resource_deps=['external-migration', 'redis'],
|
|
|
|
|
labels=['data-init'])
|
|
|
|
|
|
2025-10-30 21:08:07 +01:00
|
|
|
k8s_resource('nominatim-init',
|
|
|
|
|
labels=['data-init'])
|
|
|
|
|
|
2025-10-03 14:09:34 +02:00
|
|
|
# =============================================================================
|
|
|
|
|
# CRONJOBS
|
|
|
|
|
# =============================================================================
|
|
|
|
|
k8s_resource('demo-session-cleanup',
|
|
|
|
|
resource_deps=['demo-session-service'],
|
|
|
|
|
labels=['cronjobs'])
|
|
|
|
|
|
2025-10-09 14:11:02 +02:00
|
|
|
k8s_resource('external-data-rotation',
|
|
|
|
|
resource_deps=['external-service'],
|
|
|
|
|
labels=['cronjobs'])
|
|
|
|
|
|
2025-11-19 21:01:06 +01:00
|
|
|
k8s_resource('usage-tracker',
|
|
|
|
|
resource_deps=['tenant-service'],
|
|
|
|
|
labels=['cronjobs'])
|
|
|
|
|
|
2025-10-03 14:09:34 +02:00
|
|
|
# =============================================================================
|
|
|
|
|
# GATEWAY & FRONTEND
|
|
|
|
|
# =============================================================================
|
2025-10-01 18:58:30 +02:00
|
|
|
k8s_resource('gateway',
|
|
|
|
|
resource_deps=['auth-service'],
|
|
|
|
|
labels=['frontend'])
|
|
|
|
|
|
|
|
|
|
k8s_resource('frontend',
|
|
|
|
|
resource_deps=['gateway'],
|
|
|
|
|
labels=['frontend'])
|
|
|
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
|
# CONFIGURATION
|
|
|
|
|
# =============================================================================
|
|
|
|
|
|
|
|
|
|
# Update check interval - how often Tilt checks for file changes
|
2025-10-07 07:15:07 +02:00
|
|
|
update_settings(
|
2025-11-27 15:52:40 +01:00
|
|
|
max_parallel_updates=2, # Reduce parallel updates to avoid resource exhaustion on local machines
|
|
|
|
|
k8s_upsert_timeout_secs=120 # Increase timeout for slower local builds
|
2025-10-07 07:15:07 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Watch settings - configure file watching behavior
|
|
|
|
|
watch_settings(
|
|
|
|
|
# Ignore patterns that should never trigger rebuilds
|
|
|
|
|
ignore=[
|
|
|
|
|
'.git/**',
|
|
|
|
|
'**/__pycache__/**',
|
|
|
|
|
'**/*.pyc',
|
|
|
|
|
'**/.pytest_cache/**',
|
|
|
|
|
'**/node_modules/**',
|
|
|
|
|
'**/.DS_Store',
|
|
|
|
|
'**/*.swp',
|
|
|
|
|
'**/*.swo',
|
|
|
|
|
'**/.venv/**',
|
|
|
|
|
'**/venv/**',
|
|
|
|
|
'**/.mypy_cache/**',
|
|
|
|
|
'**/.ruff_cache/**',
|
|
|
|
|
'**/.tox/**',
|
|
|
|
|
'**/htmlcov/**',
|
|
|
|
|
'**/.coverage',
|
|
|
|
|
'**/dist/**',
|
|
|
|
|
'**/build/**',
|
2025-10-24 13:05:04 +02:00
|
|
|
'**/*.egg-info/**',
|
|
|
|
|
# Ignore TLS certificate files (don't trigger rebuilds)
|
|
|
|
|
'**/infrastructure/tls/**/*.pem',
|
|
|
|
|
'**/infrastructure/tls/**/*.cnf',
|
|
|
|
|
'**/infrastructure/tls/**/*.csr',
|
|
|
|
|
'**/infrastructure/tls/**/*.srl',
|
2025-10-30 21:08:07 +01:00
|
|
|
# Ignore temporary files from migrations and other processes
|
|
|
|
|
'**/*.tmp',
|
|
|
|
|
'**/*.tmp.*',
|
|
|
|
|
'**/migrations/versions/*.tmp.*',
|
2025-11-15 21:21:06 +01:00
|
|
|
# Ignore test artifacts and reports (playwright)
|
|
|
|
|
'**/playwright-report/**',
|
|
|
|
|
'**/test-results/**',
|
2025-10-07 07:15:07 +02:00
|
|
|
]
|
|
|
|
|
)
|
2025-10-01 18:58:30 +02:00
|
|
|
|
2025-10-24 13:05:04 +02:00
|
|
|
# Print security status on startup
|
|
|
|
|
print("""
|
|
|
|
|
✅ Security setup complete!
|
|
|
|
|
|
|
|
|
|
Database Security Features Active:
|
|
|
|
|
🔐 TLS encryption: PostgreSQL and Redis
|
|
|
|
|
🔑 Strong passwords: 32-character cryptographic
|
|
|
|
|
💾 Persistent storage: PVCs for all databases
|
|
|
|
|
🔒 Column encryption: pgcrypto extension
|
|
|
|
|
📋 Audit logging: PostgreSQL query logging
|
|
|
|
|
|
|
|
|
|
Access your application:
|
|
|
|
|
Frontend: http://localhost:3000 (or via ingress)
|
|
|
|
|
Gateway: http://localhost:8000 (or via ingress)
|
|
|
|
|
|
|
|
|
|
Verify security:
|
|
|
|
|
kubectl get pvc -n bakery-ia
|
|
|
|
|
kubectl get secrets -n bakery-ia | grep tls
|
|
|
|
|
kubectl logs -n bakery-ia <db-pod> | grep SSL
|
|
|
|
|
|
|
|
|
|
Security documentation:
|
|
|
|
|
docs/SECURITY_IMPLEMENTATION_COMPLETE.md
|
|
|
|
|
docs/DATABASE_SECURITY_ANALYSIS_REPORT.md
|
|
|
|
|
|
|
|
|
|
======================================
|
|
|
|
|
""")
|
|
|
|
|
|
2025-10-01 18:58:30 +02:00
|
|
|
# Optimize for local development
|
|
|
|
|
# Note: You may see "too many open files" warnings on macOS with many services.
|
|
|
|
|
# This is a Kind/Kubernetes limitation and doesn't affect service functionality.
|
|
|
|
|
# To work on specific services only, use: tilt up <service-name> <service-name>
|