version: '3.8'

services:
  jobmanager:
    build:
      context: ./docker/flink
    image: transfer-flink-jobmanager
    hostname: jobmanager
    container_name: transfer-jobmanager
    ports:
      - "8081:8081"
    volumes:
      - ./docker/flink/conf/flink-conf.yaml:/opt/flink/conf/flink-conf.yaml
      - ./flink/usrlib:/opt/flink/usrlib
      - ./flink/jobs:/opt/flink/jobs
    environment:
      - JOB_MANAGER_RPC_ADDRESS=jobmanager
    command: jobmanager

  taskmanager:
    build:
      context: ./docker/flink
    image: transfer-flink-taskmanager
    hostname: taskmanager
    container_name: transfer-taskmanager
    depends_on:
      - jobmanager
    volumes:
      - ./flink/usrlib:/opt/flink/usrlib
    environment:
      - JOB_MANAGER_RPC_ADDRESS=jobmanager
    command: taskmanager

  zookeeper:
    image: confluentinc/cp-zookeeper:7.4.0
    hostname: zookeeper
    container_name: transfer-zookeeper
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000

  kafka:
    image: confluentinc/cp-kafka:7.4.0
    hostname: kafka
    container_name: transfer-kafka
    ports:
      - "9092:9092"
    depends_on:
      - zookeeper
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
