version: "3"

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

  catalog:
    image: 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
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres

    volumes:
      - orderdb:/var/lib/postgresql/data
    ports:
      - "5002:5432"

  order:
    image: order:1.0
    depends_on:
      - orderdb
      - artemis
    environment:
      - SERVER_PORT=8002
      - SPRING_DATASOURCE_URL=jdbc:postgresql://orderdb:5432/postgres
      - SPRING_DATASOURCE_USERNAME=postgres
      - SPRING_DATASOURCE_PASSWORD=postgres
      - SPRING_ARTEMIS_BROKERURL=tcp://artemis:61616
      - BOOKSTORE_CATALOG_APIURL=http://catalog:8001/books
      - BOOKSTORE_PAYMENT_APIURL=http://payment:8003/payments
      - BOOKSTORE_SHIPPING_ORDERQUEUE=ShippingOrderQueue
      - BOOKSTORE_SHIPPING_CANCELQUEUE=ShippingCancelQueue
      - BOOKSTORE_SHIPPING_INFOQUEUE=ShippingInfoQueue
    ports:
      - "8002:8002"

  payment:
    image: payment:1.0
    environment:
      - SERVER_PORT=8003
    ports:
      - "8003:8003"

  artemis:
    image: quay.io/artemiscloud/activemq-artemis-broker
    environment:
      - AMQ_USER=admin
      - AMQ_PASSWORD=admin
      - AMQ_EXTRA_ARGS=--relax-jolokia
    ports:
      - "8161:8161"

  shipping:
    image: shipping:1.0
    depends_on:
      - artemis
    environment:
      - SPRING_ARTEMIS_BROKERURL=tcp://artemis:61616
      - SPRING_MAIL_HOST=mailing
      - SPRING_MAIL_PORT=25
      - BOOKSTORE_SHIPPING_ORDERQUEUE=ShippingOrderQueue
      - BOOKSTORE_SHIPPING_CANCELQUEUE=ShippingCancelQueue
      - BOOKSTORE_SHIPPING_INFOQUEUE=ShippingInfoQueue
      - BOOKSTORE_SHIPPING_PROCESSINGTIME=30000
      - BOOKSTORE_SHIPPING_MAILENABLED=true

  mailing:
    image: rnwood/smtp4dev
    ports:
      - "3000:80"

volumes:
  bookdb: {}
  orderdb: {}
