version: "3.8"

services:
  # ── Backend Django (Python) ───────────────────────────
  backend:
    build:
      context: ./crm_dreinet
      dockerfile: Dockerfile
    container_name: crm_dreinet_back
    ports:
      - "8020:8020"
    volumes:
      - ./crm_dreinet:/app
      - /var/www/html/dreinet.itego.com.ar/config/certs:/var/www/html/dreinet.itego.com.ar/config/certs:ro
    env_file:
      - ./crm_dreinet/.env
    environment:
      - DJANGO_SETTINGS_MODULE=config.settings
      - POSTGRES_HOST=vector_db
      - POSTGRES_PORT=5432
    depends_on:
      - vector_db
    networks:
      - crm_network
    restart: unless-stopped

  # ── Frontend Nuxt ─────────────────────────────────────
  frontend:
    build:
      context: ./crm_dreinet_front
      dockerfile: Dockerfile
    container_name: crm_dreinet_front
    ports:
      - "3008:3000"
    environment:
      - NUXT_PUBLIC_API_BASE=http://backend:8020/api
      - NITRO_HOST=0.0.0.0
      - NITRO_PORT=3000
    depends_on:
      - backend
    networks:
      - crm_network
    restart: unless-stopped

  # ── PostgreSQL + pgvector ─────────────────────────────
  vector_db:
    image: pgvector/pgvector:pg16
    container_name: crm_vector_db
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-postgres}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
      POSTGRES_DB: ${POSTGRES_DB:-vector_db}
    ports:
      - "5433:5432"
    volumes:
      - pg_vector_data:/var/lib/postgresql/data
    networks:
      - crm_network
    restart: unless-stopped

networks:
  crm_network:
    driver: bridge

volumes:
  pg_vector_data:
