version: '3.8'

services:
  # WebSocket OCPP Server (Production)
  ocpp-websocket-server:
    build: .
    container_name: voltie-ocpp-server
    ports:
      - "${PORT}:${PORT}"      # WebSocket server
      - "${ADMIN_PORT}:${ADMIN_PORT}"      # Admin API
    env_file:
      - .env
    environment:
      - HOST=${HOST}
      - PORT=${PORT}
      - ADMIN_ENABLED=${ADMIN_ENABLED}
      - ADMIN_PORT=${ADMIN_PORT}
      - ADMIN_TOKEN=${ADMIN_TOKEN}
      - DRIVER=${DRIVER}
      - DATABASE_HOST=${DATABASE_HOST}
      - DATABASE_PORT=${DATABASE_PORT}
      - DATABASE_NAME=${DATABASE_NAME}
      - DATABASE_USERNAME=${DATABASE_USERNAME}
      - DATABASE_PASSWORD=${DATABASE_PASSWORD}
      - LOG_LEVEL=${LOG_LEVEL}
      - HEARTBEAT_INTERVAL=${HEARTBEAT_INTERVAL}
      - OCPP_VERSION=${OCPP_VERSION}
      - MAX_CONNECTIONS=${MAX_CONNECTIONS}
    # depends_on:
    #   postgres:
    #     condition: service_healthy
    restart: unless-stopped
    networks:
      - voltie-network

  # UDP Client (Testing/Development)
  # ocpp-udp-client:
  #   build: .
  #   container_name: voltie-ocpp-client
  #   command: python -m client.server
  #   ports:
  #     - "${UDP_CLIENT_PORT}:${UDP_CLIENT_PORT}/udp"  # UDP server port
  #   environment:
  #     - UDP_HOST=${UDP_CLIENT_HOST}
  #     - UDP_PORT=${UDP_CLIENT_PORT}
  #     - BACKEND_URL=${BACKEND_URL}
  #     - DRIVER=${DRIVER}
  #     - LOG_LEVEL=${LOG_LEVEL}
  #   restart: unless-stopped
  #   networks:
  #     - voltie-network

  # PostgreSQL Database
  # postgres:
  #   image: postgres:16-alpine
  #   container_name: voltie-postgres
  #   environment:
  #     - POSTGRES_DB=ocpp_db
  #     - POSTGRES_USER=ocpp
  #     - POSTGRES_PASSWORD=password
  #   volumes:
  #     - postgres_data:/var/lib/postgresql/data
  #   ports:
  #     - "5432:5432"
  #   healthcheck:
  #     test: ["CMD-SHELL", "pg_isready -U ocpp -d ocpp_db"]
  #     interval: 10s
  #     timeout: 5s
  #     retries: 5
  #   restart: unless-stopped
  #   networks:
  #     - voltie-network

  # Redis (Optional - for client caching)
  # redis:
  #   image: redis:7-alpine
  #   container_name: voltie-redis
  #   ports:
  #     - "6379:6379"
  #   volumes:
  #     - redis_data:/data
  #   restart: unless-stopped
  #   networks:
  #     - voltie-network

  # Frontend - Charging Station Simulator
  voltie-frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: voltie-frontend
    ports:
      - "3000:3000"      # Frontend web interface
    env_file:
      - ./frontend/.env
    depends_on:
      - ocpp-websocket-server
    restart: unless-stopped
    networks:
      - voltie-network

# volumes:
#   postgres_data:
networks:
  voltie-network:
    driver: bridge
