services:
  platform-frontend-v2:
    build:
      context: ./frontend-v2
      dockerfile: Dockerfile
    container_name: platform-frontend-v2
    restart: unless-stopped
    volumes:
      - ./screenshots:/app/screenshots
    environment:
      - ORIGIN=${PLATFORM_V2_ORIGIN:-https://dash.quadjourney.com}
      - GATEWAY_URL=http://gateway:8100
      - DEV_AUTO_LOGIN=${DEV_AUTO_LOGIN:-0}
      - IMMICH_URL=${IMMICH_URL}
      - IMMICH_API_KEY=${IMMICH_API_KEY}
      - KARAKEEP_URL=${KARAKEEP_URL:-http://192.168.1.42:3005}
      - KARAKEEP_API_KEY=${KARAKEEP_API_KEY}
      - BODY_SIZE_LIMIT=52428800
      - TZ=${TZ:-America/Chicago}
    networks:
      default:
      pangolin:
        ipv4_address: 172.16.1.50
    depends_on:
      - gateway

  gateway:
    build:
      context: ./gateway
      dockerfile: Dockerfile
    container_name: platform-gateway
    restart: unless-stopped
    volumes:
      - ./gateway/data:/app/data
      - /media/yusiboyz/Media/Scripts/booklore/booklore/books:/booklore-books:ro
      - /media/yusiboyz/Media/Scripts/shelfmark/books:/bookdrop:ro
    environment:
      - ADMIN_USERNAME=${ADMIN_USERNAME}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - ADMIN_DISPLAY_NAME=${ADMIN_DISPLAY_NAME:-Admin}
      - DEV_AUTO_LOGIN=${DEV_AUTO_LOGIN:-0}
      - DEV_AUTO_LOGIN_USERNAME=${DEV_AUTO_LOGIN_USERNAME:-dev}
      - DEV_AUTO_LOGIN_DISPLAY_NAME=${DEV_AUTO_LOGIN_DISPLAY_NAME:-Dev User}
      - PORT=8100
      - TRIPS_BACKEND_URL=http://trips-service:8087
      - FITNESS_BACKEND_URL=http://fitness-service:8095
      - INVENTORY_BACKEND_URL=http://inventory-service:3000
      - INVENTORY_SERVICE_API_KEY=${INVENTORY_SERVICE_API_KEY}
      - BUDGET_SERVICE_API_KEY=${BUDGET_SERVICE_API_KEY}
      - MINIFLUX_URL=${MINIFLUX_URL:-http://miniflux:8080}
      - MINIFLUX_API_KEY=${MINIFLUX_API_KEY}
      - TRIPS_API_TOKEN=${TRIPS_API_TOKEN}
      - NOCODB_API_TOKEN=${NOCODB_API_TOKEN}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - OPENAI_MODEL=${OPENAI_MODEL:-gpt-5.2}
      - SHELFMARK_URL=${SHELFMARK_URL:-http://shelfmark:8084}
      - BOOKLORE_URL=${BOOKLORE_URL:-http://booklore:6060}
      - BOOKLORE_USER=${BOOKLORE_USER}
      - BOOKLORE_PASS=${BOOKLORE_PASS}
      - KARAKEEP_URL=${KARAKEEP_URL:-http://192.168.1.42:3005}
      - KARAKEEP_API_KEY=${KARAKEEP_API_KEY}
      - SPOTIZERR_URL=${SPOTIZERR_URL:-http://spotizerr-app:7171}
      - BUDGET_BACKEND_URL=http://budget-service:3001
      - TASKS_BACKEND_URL=http://tasks-service:8098
      - TASKS_SERVICE_API_KEY=${TASKS_SERVICE_API_KEY}
      - BRAIN_BACKEND_URL=http://brain-api:8200
      - QBITTORRENT_HOST=${QBITTORRENT_HOST:-192.168.1.42}
      - QBITTORRENT_PORT=${QBITTORRENT_PORT:-8080}
      - QBITTORRENT_USERNAME=${QBITTORRENT_USERNAME:-admin}
      - QBITTORRENT_PASSWORD=${QBITTORRENT_PASSWORD}
      - SMTP2GO_API_KEY=${SMTP2GO_API_KEY}
      - SMTP2GO_FROM_EMAIL=${SMTP2GO_FROM_EMAIL}
      - SMTP2GO_FROM_NAME=${SMTP2GO_FROM_NAME:-Platform}
      - KINDLE_EMAIL_1=${KINDLE_EMAIL_1}
      - KINDLE_EMAIL_2=${KINDLE_EMAIL_2}
      - KINDLE_LABELS=${KINDLE_LABELS:-Madiha,Hafsa}
      - TZ=${TZ:-America/Chicago}
    networks:
      - default
      - pangolin
    depends_on:
      - trips-service
      - fitness-service
      - inventory-service
      - budget-service
      - tasks-service

  tasks-service:
    build:
      context: ./services/tasks
      dockerfile: Dockerfile
    container_name: platform-tasks-service
    restart: unless-stopped
    volumes:
      - ./services/tasks/data:/app/data
    environment:
      - PORT=8098
      - TZ=${TZ:-America/Chicago}

  trips-service:
    build:
      context: ./services/trips
      dockerfile: Dockerfile
    container_name: platform-trips-service
    restart: unless-stopped
    volumes:
      - ./services/trips/data:/app/data
    env_file:
      - ./services/trips/.env
    environment:
      - TZ=${TZ:-America/Chicago}

  fitness-service:
    build:
      context: ./services/fitness
      dockerfile: Dockerfile.backend
    container_name: platform-fitness-service
    restart: unless-stopped
    volumes:
      - ./services/fitness/data:/app/data
    env_file:
      - ./services/fitness/.env
    environment:
      - PORT=8095
      - DATA_DIR=/app/data
      - TZ=${TZ:-America/Chicago}

  inventory-service:
    build:
      context: ./services/inventory
      dockerfile: Dockerfile
    container_name: platform-inventory-service
    restart: unless-stopped
    environment:
      - PORT=3000
      - NOCODB_URL=${NOCODB_URL:-http://nocodb:8080}
      - NOCODB_PUBLIC_URL=${NOCODB_PUBLIC_URL:-https://noco.quadjourney.com}
      - NOCODB_API_TOKEN=${NOCODB_API_TOKEN}
      - NOCODB_BASE_ID=${NOCODB_BASE_ID:-pava9q9zccyihpt}
      - NOCODB_TABLE_ID=${NOCODB_TABLE_ID:-mash7c5nx4unukc}
      - NOCODB_COLUMN_NAME=${NOCODB_COLUMN_NAME:-photos}
      - DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
      - PUBLIC_APP_URL=${PLATFORM_ORIGIN}/inventory
      - IMMICH_URL=${IMMICH_URL}
      - IMMICH_API_KEY=${IMMICH_API_KEY}
      - SERVICE_API_KEY=${INVENTORY_SERVICE_API_KEY}
      - TZ=${TZ:-America/Chicago}
    networks:
      - default
      - nocodb_default

  budget-service:
    build:
      context: ./services/budget
      dockerfile: Dockerfile
    container_name: platform-budget-service
    restart: unless-stopped
    environment:
      - PORT=3001
      - ACTUAL_SERVER_URL=http://actualbudget:5006
      - ACTUAL_PASSWORD=${ACTUAL_PASSWORD}
      - ACTUAL_SYNC_ID=${BUDGET_SYNC_ID}
      - SERVICE_API_KEY=${BUDGET_SERVICE_API_KEY}
      - TZ=${TZ:-America/Chicago}
    networks:
      - default
      - actualbudget_default

networks:
  nocodb_default:
    external: true
  pangolin:
    external: true
  actualbudget_default:
    external: true
