services:
  bookdb:
    image: postgres:18.1
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    volumes:
      - bookdb:/var/lib/postgresql/18/docker
    ports:
      - "5001:5432"

  catalog:
    image: bookstore/catalog:1.0
    depends_on:
      - bookdb
    environment:
      - SERVER_PORT=8001
      - SPRING_DATASOURCE_URL=jdbc:postgresql://bookdb:5432/postgres
      - SPRING_DATASOURCE_USERNAME=postgres
      - SPRING_DATASOURCE_PASSWORD=postgres
    ports:
      - "8001:8001"

  orderdb:
    image: postgres:18.1
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    volumes:
      - orderdb:/var/lib/postgresql/18/docker
    ports:
      - "5002:5432"

  activemq:
    image: apache/activemq-classic:6.2.0
    environment:
      - ACTIVEMQ_USER=admin
      - ACTIVEMQ_PASSWORD=admin
    ports:
      - "8161:8161"

  order:
    image: bookstore/order:1.0
    depends_on:
      - orderdb
      - activemq
    environment:
      - SERVER_PORT=8002
      - SPRING_DATASOURCE_URL=jdbc:postgresql://orderdb:5432/postgres
      - SPRING_DATASOURCE_USERNAME=postgres
      - SPRING_DATASOURCE_PASSWORD=postgres
      - SPRING_ACTIVEMQ_BROKERURL=tcp://activemq:61616
      - BOOKSTORE_CATALOG_APIURL=http://catalog:8001/books
      - BOOKSTORE_SHIPPING_ORDERQUEUE=OrderQueue
      - BOOKSTORE_SHIPPING_CANCELQUEUE=CancelQueue
      - BOOKSTORE_SHIPPING_INFOQUEUE=InfoQueue
    ports:
      - "8002:8002"

  shipping:
    image: bookstore/shipping:1.0
    depends_on:
      - activemq
    environment:
      - SPRING_ACTIVEMQ_BROKERURL=tcp://activemq:61616
      - BOOKSTORE_SHIPPING_ORDERQUEUE=OrderQueue
      - BOOKSTORE_SHIPPING_CANCELQUEUE=CancelQueue
      - BOOKSTORE_SHIPPING_INFOQUEUE=InfoQueue
      - BOOKSTORE_SHIPPING_PROCESSINGTIME=300000

volumes:
  bookdb: {}
  orderdb: {}
