version: '3.8'

services:
  # ===========================================
  # MICROSERVICE DE RECHERCHE
  # ===========================================
  search-microservice:
    build:
      context: .
      dockerfile: Dockerfile.prod
    container_name: search-microservice
    restart: unless-stopped
    ports:
      - "8003:8003"
    environment:
      - APP_ENV=prod
      - APP_DEBUG=0
    env_file:
      - .env.prod
    volumes:
      - ./var/log:/app/var/log
      - ./var/cache:/app/var/cache
    networks:
      - microservices
    depends_on:
      - redis
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8003/api/search/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  # ===========================================
  # REDIS POUR LE CACHE
  # ===========================================
  redis:
    image: redis:7-alpine
    container_name: search-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - microservices
    command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru

  # ===========================================
  # REVERSE PROXY NGINX
  # ===========================================
  nginx:
    image: nginx:alpine
    container_name: search-nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/ssl:/etc/nginx/ssl:ro
      - ./var/log/nginx:/var/log/nginx
    networks:
      - microservices
    depends_on:
      - search-microservice

networks:
  microservices:
    driver: bridge

volumes:
  redis_data:
    driver: local