services:

  nifi:
    image: apache/nifi:1.27.0
    ports:
      - 18443:8443 # Unsecured HTTP Web Port
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      - SINGLE_USER_CREDENTIALS_USERNAME=admin
      - SINGLE_USER_CREDENTIALS_PASSWORD=Password123456
      - NIFI_WEB_HTTP_PORT=8443
    volumes:
      - ./drivers:/opt/nifi/nifi-current/drivers
      - ./shared-folder:/opt/nifi/nifi-current/ls-target
      - nifi-conf:/opt/nifi/nifi-current/conf
      - nifi-state:/opt/nifi/nifi-current/state
      # Если хочешь сохранять очереди/контент/провенанс (обычно для обучения не нужно) — раскомментируй:
      # - nifi-flowfile-repo:/opt/nifi/nifi-current/flowfile_repository
      # - nifi-content-repo:/opt/nifi/nifi-current/content_repository
      # - nifi-provenance-repo:/opt/nifi/nifi-current/provenance_repository
      # - nifi-database-repo:/opt/nifi/nifi-current/database_repository

  registry:
    image: apache/nifi-registry:1.27.0
    ports:
      - 18080:18080
    environment:
      - NIFI_REGISTRY_WEB_HTTP_PORT=18080
    volumes:
      - registry-db:/opt/nifi-registry/nifi-registry-current/database
      - registry-flow-storage:/opt/nifi-registry/nifi-registry-current/flow_storage
      
  postgres:
    image: postgres:16.4
    # restart: always
    ports:
      - 5437:5432
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: app
    volumes:
      - pgdata:/var/lib/postgresql/data
      - ./nifi-templates:/nifi-templates
    
  kafka:
    image: apache/kafka:3.8.0
    hostname: kafka
    container_name: kafka
    ports:
      - 9092:9092
    # Если хочешь сохранять топики/сообщения между `docker compose down/up` — раскомментируй:
    # volumes:
    #   - kafka-data:/tmp/kraft-combined-logs
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT,CONTROLLER:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
      KAFKA_PROCESS_ROLES: broker,controller
      KAFKA_NODE_ID: 1
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:29093
      KAFKA_LISTENERS: PLAINTEXT://kafka:29092,CONTROLLER://kafka:29093,PLAINTEXT_HOST://0.0.0.0:9092
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_LOG_DIRS: /tmp/kraft-combined-logs
      CLUSTER_ID: MkU3OEVBNTcwNTJENDM2Qk

  kafka-ui:
    container_name: kafka-ui
    image: provectuslabs/kafka-ui:v0.7.2
    ports:
      - 8082:8080
    depends_on:
      - kafka
    environment:
      DYNAMIC_CONFIG_ENABLED: "true"
      KAFKA_CLUSTERS_0_NAME: "Kafka Cluster"
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: "kafka:29092"
      KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL: "PLAINTEXT"

volumes:
  pgdata:
  nifi-conf:
  nifi-state:
  registry-db:
  registry-flow-storage:
  # nifi-flowfile-repo:
  # nifi-content-repo:
  # nifi-provenance-repo:
  # nifi-database-repo:
  # kafka-data:
