version: '3.7'

services:

  db:
    image: library/postgres:9.6.24-alpine
    ports:
      - "5432:5432"
    environment:
      - "POSTGRES_DB=openfire"
      - "POSTGRES_USER=openfire"
      - "POSTGRES_PASSWORD=hunter2"
    volumes:
      - ./sql/clustered:/docker-entrypoint-initdb.d

  lb:
    image: nginx:stable
    ports:
      - "55222:55222"
      - "57070:57070"
      - "57443:57443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf

  xmpp1:
    image: "openfire:${OPENFIRE_TAG}"
    ports:
      - "5221:5222"
      - "5261:5269"
      - "7071:7070"
      - "7441:7443"
      - "9091:9090"
    depends_on:
      - "db"
    volumes:
      - ./_data/xmpp/1/conf:/var/lib/openfire/conf
      - ./_data/plugins:/opt/plugins
      - ../_common/wait-for-it.sh:/wait-for-it.sh
    command: ["/wait-for-it.sh", "-s", "db:5432", "--", "/sbin/entrypoint.sh", "-Dhazelcast.prefer.ipv4.stack=${PREFER_IPV4} -Djava.net.preferIPv6Addresses=${PREFER_IPV6}"]

  xmpp2:
    image: "openfire:${OPENFIRE_TAG}"
    ports:
      - "5222:5222"
      - "5262:5269"
      - "7072:7070"
      - "7442:7443"
      - "9092:9090"
    depends_on:
      - "db"
    volumes:
      - ./_data/xmpp/2/conf:/var/lib/openfire/conf
      - ./_data/plugins:/opt/plugins
      - ../_common/wait-for-it.sh:/wait-for-it.sh
    command: ["/wait-for-it.sh", "-s", "db:5432", "--", "/sbin/entrypoint.sh", "-Dhazelcast.prefer.ipv4.stack=${PREFER_IPV4} -Djava.net.preferIPv6Addresses=${PREFER_IPV6}"]

  xmpp3:
    image: "openfire:${OPENFIRE_TAG}"
    ports:
      - "5223:5222"
      - "5263:5269"
      - "7073:7070"
      - "7443:7443"
      - "9093:9090"
    depends_on:
      - "db"
    volumes:
      - ./_data/xmpp/3/conf:/var/lib/openfire/conf
      - ./_data/plugins:/opt/plugins
      - ../_common/wait-for-it.sh:/wait-for-it.sh
    command: ["/wait-for-it.sh", "-s", "db:5432", "--", "/sbin/entrypoint.sh", "-Dhazelcast.prefer.ipv4.stack=${PREFER_IPV4} -Djava.net.preferIPv6Addresses=${PREFER_IPV6}"]

  otherdb:
    image: library/postgres:9.6.24-alpine
    ports:
      - "5433:5432"
    environment:
      - "POSTGRES_DB=openfire"
      - "POSTGRES_USER=openfire"
      - "POSTGRES_PASSWORD=hunter2"
    volumes:
      - ./sql/otherdomain:/docker-entrypoint-initdb.d

  otherxmpp:
    image: "openfire:${OPENFIRE_TAG}"
    ports:
      - "5229:5222"
      - "5269:5269"
      - "7079:7070"
      - "7449:7443"
      - "9099:9090"
    depends_on:
      - "otherdb"
    volumes:
      - ./_data/xmpp/otherdomain/conf:/var/lib/openfire/conf
      - ./_data/plugins_for_otherdomain:/opt/plugins
      - ../_common/wait-for-it.sh:/wait-for-it.sh
    command: ["/wait-for-it.sh", "-s", "otherdb:5432", "--", "/sbin/entrypoint.sh"]

  dozzle:
    image: amir20/dozzle:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 9999:8080
