161 lines
4.6 KiB
YAML
161 lines
4.6 KiB
YAML
# Website Analyzer - Docker Compose Configuration
|
|
# This file orchestrates all services required for the application
|
|
|
|
version: '3.9'
|
|
|
|
services:
|
|
# ==========================================================================
|
|
# PostgreSQL Database
|
|
# ==========================================================================
|
|
db:
|
|
image: postgres:16-alpine
|
|
container_name: analyzer_db
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: analyzer
|
|
POSTGRES_PASSWORD: analyzer_password
|
|
POSTGRES_DB: website_analyzer
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
ports:
|
|
- "5432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U analyzer -d website_analyzer"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# ==========================================================================
|
|
# Redis - Message Broker & Cache
|
|
# ==========================================================================
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: analyzer_redis
|
|
restart: unless-stopped
|
|
ports:
|
|
- "6379:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# ==========================================================================
|
|
# Django Web Application
|
|
# ==========================================================================
|
|
web:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: analyzer_web
|
|
restart: unless-stopped
|
|
command: >
|
|
sh -c "python manage.py migrate &&
|
|
python manage.py collectstatic --noinput &&
|
|
gunicorn core.wsgi:application --bind 0.0.0.0:8000 --workers 4 --threads 2"
|
|
volumes:
|
|
- ./backend:/app
|
|
- static_volume:/app/staticfiles
|
|
ports:
|
|
- "8000:8000"
|
|
env_file:
|
|
- ./backend/.env
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/api/health/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# ==========================================================================
|
|
# Celery Worker - Background Task Processing
|
|
# ==========================================================================
|
|
celery_worker:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: analyzer_celery_worker
|
|
restart: unless-stopped
|
|
command: celery -A core worker -l INFO --concurrency=2
|
|
volumes:
|
|
- ./backend:/app
|
|
env_file:
|
|
- ./backend/.env
|
|
depends_on:
|
|
- db
|
|
- redis
|
|
- web
|
|
|
|
# ==========================================================================
|
|
# Celery Beat - Scheduled Tasks (Optional)
|
|
# ==========================================================================
|
|
celery_beat:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: analyzer_celery_beat
|
|
restart: unless-stopped
|
|
command: celery -A core beat -l INFO
|
|
volumes:
|
|
- ./backend:/app
|
|
env_file:
|
|
- ./backend/.env
|
|
depends_on:
|
|
- db
|
|
- redis
|
|
- celery_worker
|
|
|
|
# ==========================================================================
|
|
# OWASP ZAP - Security Scanner
|
|
# ==========================================================================
|
|
zap:
|
|
image: ghcr.io/zaproxy/zaproxy:stable
|
|
container_name: analyzer_zap
|
|
restart: unless-stopped
|
|
command: zap.sh -daemon -host 0.0.0.0 -port 8080 -config api.key=zap-api-key-change-me -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true
|
|
ports:
|
|
- "8081:8080"
|
|
volumes:
|
|
- zap_data:/home/zap/.ZAP
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/JSON/core/view/version/?apikey=zap-api-key-change-me"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 5
|
|
|
|
# ==========================================================================
|
|
# Lighthouse Scanner Service (Node.js)
|
|
# ==========================================================================
|
|
lighthouse:
|
|
build:
|
|
context: ./lighthouse
|
|
dockerfile: Dockerfile
|
|
container_name: analyzer_lighthouse
|
|
restart: unless-stopped
|
|
ports:
|
|
- "3001:3001"
|
|
volumes:
|
|
- lighthouse_reports:/app/reports
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
static_volume:
|
|
zap_data:
|
|
lighthouse_reports:
|
|
|
|
networks:
|
|
default:
|
|
name: analyzer_network
|