services:
  cargoradar:
    build: .
    container_name: cargoradar
    restart: unless-stopped
    ports:
      - "${CARGORADAR_PORT:-8080}:8080"
    environment:
      HOST: 0.0.0.0
      PORT: 8080
      DATA_DIR: /data
      WEB_ROOT: /app/apps/web/public
      ADMIN_TOKEN: ${ADMIN_TOKEN:-}
      ADMIN_AUTH_REQUIRED: ${ADMIN_AUTH_REQUIRED:-false}
      KAKAO_JAVASCRIPT_KEY: ${KAKAO_JAVASCRIPT_KEY:-}
      KAKAO_REST_API_KEY: ${KAKAO_REST_API_KEY:-}
      OSRM_ROUTE_URL: ${OSRM_ROUTE_URL:-https://router.project-osrm.org/route/v1/driving}
      SIMULATOR_ENABLED: ${SIMULATOR_ENABLED:-true}
      SIMULATOR_INTERVAL_MS: ${SIMULATOR_INTERVAL_MS:-5000}
      SIMULATOR_SPEED_SCALE: ${SIMULATOR_SPEED_SCALE:-1}
    volumes:
      - ./runtime-data:/data
      - ./apps/server/src:/app/apps/server/src:ro
      - ./apps/web/public:/app/apps/web/public:ro
    healthcheck:
      test:
        - CMD
        - node
        - -e
        - "fetch('http://127.0.0.1:8080/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s
