name: lhia-replies
services:
  gateway-facebook:
    build: ./gateway-facebook
    image: ${DOCKER_REGISTRY:-lhia-replies-services}/gateway-facebook:${IMAGE_TAG:-latest}
    container_name: ${CLIENT_NAME}-gateway-facebook
    ports:
      - "${PORT_GW_FB}:8010"
    environment:
      - SERVER_PORT=8010
      - URL_COMENTARIOS_FACEBOOK=http://comentarios-facebook:8011/facebook-${CLIENT_NAME}/webhook
      - META_FACEBOOK_VERIFY_TOKEN=${FB_VERIFY_TOKEN}
      - JAVA_TOOL_OPTIONS=-Dlogging.file.name=/app/logs/gateway-facebook.log
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./logs:/app/logs
    networks:
      - lhia-replies
    logging: &default-logging
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  gateway-instagram:
    build: ./gateway-instagram
    image: ${DOCKER_REGISTRY:-lhia-replies-services}/gateway-instagram:${IMAGE_TAG:-latest}
    container_name: ${CLIENT_NAME}-gateway-instagram
    ports:
      - "${PORT_GW_IG}:8020"
    environment:
      - SERVER_PORT=8020
      - URL_COMENTARIOS_INSTAGRAM=http://comentarios-instagram:8021/instagram-${CLIENT_NAME}/webhook
      - META_INSTAGRAM_VERIFY_TOKEN=${IG_VERIFY_TOKEN}
      - JAVA_TOOL_OPTIONS=-Dlogging.file.name=/app/logs/gateway-instagram.log
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./logs:/app/logs
    networks:
      - lhia-replies
    logging: *default-logging

  comentarios-facebook:
    build: ./comentarios-facebook
    image: ${DOCKER_REGISTRY:-lhia-replies-services}/comentarios-facebook:${IMAGE_TAG:-latest}
    container_name: ${CLIENT_NAME}-comentarios-facebook
    ports:
      - "${PORT_COM_FB}:8011"
    environment:
      - SERVER_PORT=8011
      - WEBFLUX_BASE_PATH=${WEBFLUX_BASE_PATH_FB}
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_NAME=${DB_NAME}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - DB_SCHEMA_FB=${DB_SCHEMA_FB}
      - FB_BEARER_TOKEN=${FB_BEARER_TOKEN}
      - FB_PAGE_ID=${FB_PAGE_ID}
      - FB_VERIFY_TOKEN=${FB_VERIFY_TOKEN}
      - LHIA_TOKEN_PASSWORD=${LHIA_TOKEN_PASSWORD}
      - LHIA_FILE_SAVE_URL=${LHIA_FILE_SAVE_URL}
      - LHIA_V3_URL=http://lhia-v3-agent:8014/lhia-v3-${CLIENT_NAME}
      - LHIA_FAQS_URL=http://lhia-faqs:8013/lhia-${CLIENT_NAME}
      - LHIA_EMBEDDINGS_URL=http://lhia-embeddings:8012/embed
      - LHIA_VISION_URL=http://host.docker.internal:8003/lhia-vision/analyze
      - LOGGING_FILE_NAME=/app/logs/comentarios-facebook.log
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./logs:/app/logs
    networks:
      - lhia-replies
    logging: *default-logging

  comentarios-instagram:
    build: ./comentarios-instagram
    image: ${DOCKER_REGISTRY:-lhia-replies-services}/comentarios-instagram:${IMAGE_TAG:-latest}
    container_name: ${CLIENT_NAME}-comentarios-instagram
    ports:
      - "${PORT_COM_IG}:8021"
    environment:
      - SERVER_PORT=8021
      - WEBFLUX_BASE_PATH=${WEBFLUX_BASE_PATH_IG}
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_NAME=${DB_NAME}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - DB_SCHEMA_IG=${DB_SCHEMA_IG}
      - IG_BEARER_TOKEN=${IG_BEARER_TOKEN}
      - IG_PAGE_ID=${IG_PAGE_ID}
      - IG_VERIFY_TOKEN=${IG_VERIFY_TOKEN}
      - LHIA_TOKEN_PASSWORD=${LHIA_TOKEN_PASSWORD}
      - LHIA_FILE_SAVE_URL=${LHIA_FILE_SAVE_URL}
      - LHIA_V3_URL=http://lhia-v3-agent:8014/lhia-v3-${CLIENT_NAME}
      - LHIA_FAQS_URL=http://lhia-faqs:8013/lhia-${CLIENT_NAME}
      - LHIA_EMBEDDINGS_URL=http://lhia-embeddings:8012/embed
      - LHIA_VISION_URL=http://host.docker.internal:8003/lhia-vision/analyze
      - LOGGING_FILE_NAME=/app/logs/comentarios-instagram.log
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./logs:/app/logs
    networks:
      - lhia-replies
    logging: *default-logging

  lhia-embeddings:
    build: ./lhia-embeddings
    image: ${DOCKER_REGISTRY:-lhia-replies-services}/lhia-embeddings:${IMAGE_TAG:-latest}
    container_name: ${CLIENT_NAME}-lhia-embeddings
    ports:
      - "${PORT_EMBED}:8012"
    environment:
      - PORT=8012
      - OPENAI_API_KEY=${OPENAI_API_KEY}
    entrypoint: ["sh", "-c", "python main.py 2>&1 | tee /app/logs/lhia-embeddings.log"]
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./logs:/app/logs
    networks:
      - lhia-replies
    logging: *default-logging

  lhia-faqs:
    build: ./lhia-faqs
    image: ${DOCKER_REGISTRY:-lhia-replies-services}/lhia-faqs:${IMAGE_TAG:-latest}
    container_name: ${CLIENT_NAME}-lhia-faqs
    ports:
      - "${PORT_FAQS}:8013"
    environment:
      - PORT=8013
      - CLIENT_NAME=${CLIENT_NAME}
      - NEO4J_URI=${NEO4J_URI}
      - NEO4J_USER=${NEO4J_USER}
      - NEO4J_PASSWORD=${NEO4J_PASSWORD}
      - NEO4J_DATABASE=${NEO4J_DATABASE}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
    entrypoint: ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 8013 2>&1 | tee /app/logs/lhia-faqs.log"]
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./logs:/app/logs
    networks:
      - lhia-replies
    logging: *default-logging

  lhia-v3-agent:
    build: ./lhia-v3-agent
    image: ${DOCKER_REGISTRY:-lhia-replies-services}/lhia-v3-agent:${IMAGE_TAG:-latest}
    container_name: ${CLIENT_NAME}-lhia-v3-agent
    ports:
      - "${PORT_AGENT}:8014"
    environment:
      - PORT=8014
      - CLIENT_NAME=${CLIENT_NAME}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - LHIA_FAQS_URL=http://lhia-faqs:8013/lhia-${CLIENT_NAME}
      - LHIA_EMBEDDINGS_URL=http://lhia-embeddings:8012
    entrypoint: ["sh", "-c", "python api_server.py 2>&1 | tee /app/logs/lhia-v3-agent.log"]
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./logs:/app/logs
    networks:
      - lhia-replies
    logging: *default-logging

networks:
  lhia-replies:
    driver: bridge
    ipam:
      config:
        - subnet: ${DOCKER_SUBNET}
