
services:
  kilas:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: kilas-gateway
    restart: unless-stopped
    ports:
      - "${PORT:-3001}:${PORT:-3001}"
    environment:
      - NODE_ENV=production
      - PORT=${PORT:-3001}
      - ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin123}
      - SESSION_DIR=/app/sessions
      - MEDIA_DIR=/app/media
      - DATA_DIR=/app/data
      - API_KEY=${API_KEY:-admin123}
      - CORS_ORIGIN=${CORS_ORIGIN:-*}
    volumes:
      # Use named volumes for automatic permission handling
      - sessions_data:/app/sessions
      - media_data:/app/media
      - db_data:/app/data
    networks:
      - kilas-network
    # healthcheck:
    #   test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/api/sessions', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
    #   interval: 30s
    #   timeout: 10s
    #   retries: 3
    #   start_period: 40s
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

networks:
  kilas-network:
    driver: bridge

volumes:
  sessions_data:
    driver: local
  media_data:
    driver: local
  db_data:
    driver: local
