# docker-compose.full.yml
# Synced with streamlined infrastructure
version: '3.8'

services:
  redis:
    image: redis:7-alpine
    container_name: re_workflow_redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - re_workflow_network
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  clamav:
    image: clamav/clamav:latest
    container_name: re_clamav
    ports:
      - "3310:3310"
    volumes:
      - clamav_data:/var/lib/clamav
    environment:
      - CLAMAV_NO_FRESHCLAMD=false
    healthcheck:
      test: ["CMD", "clamdcheck"]
      interval: 60s
      timeout: 10s
      retries: 5
      start_period: 120s
    restart: unless-stopped
    networks:
      - re_workflow_network

  loki:
    image: grafana/loki:2.9.2
    container_name: re_loki
    ports:
      - "3100:3100"
    volumes:
      - ./monitoring/loki/loki-config.yml:/etc/loki/local-config.yaml:ro
      - loki_data:/loki
    command: -config.file=/etc/loki/local-config.yaml
    networks:
      - re_workflow_network
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 5

  promtail:
    image: grafana/promtail:2.9.2
    container_name: re_promtail
    volumes:
      - ./monitoring/promtail/promtail-config.yml:/etc/promtail/config.yml:ro
      - ./logs:/var/log/app:ro
      - promtail_data:/tmp/promtail
    command: -config.file=/etc/promtail/config.yml
    depends_on:
      - loki
    networks:
      - re_workflow_network
    restart: unless-stopped

  grafana:
    image: grafana/grafana:10.2.2
    container_name: re_grafana
    ports:
      - "3001:3000"
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=REWorkflow@2024
      - GF_USERS_ALLOW_SIGN_UP=false
    volumes:
      - grafana_data:/var/lib/grafana
      - ./monitoring/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
      - ./monitoring/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
      - ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro
    depends_on:
      - loki
    networks:
      - re_workflow_network
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3

volumes:
  redis_data:
  clamav_data:
  loki_data:
  promtail_data:
  grafana_data:

networks:
  re_workflow_network:
    driver: bridge
