version: '3.3'

services:
  artix-delivery:
    restart: always
    image: dockerregistry.artix.su:2443/delivery:latest
    container_name: delivery
    environment:
      kafka.enabled: 'true'
      kafka.server.ip: kafka
      kafka.server.port: 29092
      messaging.service.enabled: 'false'
      postgresql_db: postgresql
    volumes:
      - /etc/localtime:/etc/localtime:ro
    ports:
      - 18099:18099
    depends_on:
      - postgresql
    networks:
      - delivery_network

  artix-delivery-webapp:
    restart: always
    image: dockerregistry.artix.su:2443/artix.delivery.webapp:latest
    container_name: delivery-webapp
    environment:
      service.host: delivery
      service.port: 18099
      service.login: admin
      service.password: admin
    ports:
      - 18065:18065
    depends_on:
      - artix-delivery
    networks:
      - delivery_network

  zookeeper:
    restart: always
    image: confluentinc/cp-zookeeper:latest
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
    container_name: zookeeper
    ports:
      - 22181:2181
    networks:
      - delivery_network
    volumes:
      - ${PWD}/secrets:/etc/kafka/secrets

  kafka:
    restart: always
    image: confluentinc/cp-kafka:latest
    depends_on:
      - zookeeper
    ports:
      - 29092:29092
    container_name: kafka
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LISTENERS: INTERNAL://0.0.0.0:9092,OUTSIDE://0.0.0.0:29092
      KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9092,OUTSIDE://localhost:29092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,OUTSIDE:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
    networks:
      - delivery_network

  kafka-ui:
    restart: always
    container_name: kafka-ui
    image: provectuslabs/kafka-ui:latest
    ports:
      - 18080:8080
    environment:
      DYNAMIC_CONFIG_ENABLED: 'true'
      AUTH_TYPE: "LOGIN_FORM"
      SPRING_SECURITY_USER_NAME: admin
      SPRING_SECURITY_USER_PASSWORD: admin
      KAFKA_CLUSTERS_0_NAME: delivery
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
    networks:
      - delivery_network

  postgresql:
    restart: always
    image: postgres:15.2
    container_name: postgresql
    environment:
      POSTGRES_USER: "netroot"
      POSTGRES_PASSWORD: "netroot"
      POSTGRES_DB: "delivery"
    volumes:
      - postgres-data:/var/lib/postgresql/data
    ports:
      - 15432:5432
    networks:
      - delivery_network

networks:
  delivery_network:

volumes:
  postgres-data: