version: "2.1"
services:
  # IBM will not provide Db2 Docker, but you can build one yourself
  #db:
  #  image: ts-db:latest
  #  hostname: auth_db
  #  privileged: true
  #  environment:
  #    - LICENSE=accept
  #    - TZ=Asia/Shanghai
  #  ports:
  #    - 50000:50000
  #  healthcheck:
  #   test: exit 0

  txn:
    image: ts-app:latest
    hostname: auth_txn
    environment:
      - LICENSE=accept
      - TZ=Asia/Shanghai
    ports:
      - 5080:5080
      - 5443:5443
      - 9060:9060
      - 9043:9043
    extra_hosts:
    # IF you already have a Db2 Docker container, you can remove this extra_host config for database
      - "db:<DB server IP>"
    networks:
      default:
        aliases:
          - app
    depends_on:
      db:
        condition: service_started
    healthcheck:
      test: curl -f http://localhost:5080/wcs/resources/health/ping
      interval: 10s
      retries: 50

  web:
    image: ts-web:latest
    hostname: auth_web
    environment:
      - LICENSE=accept
      - TZ=Asia/Shanghai
    ports:
      - 80:80
      - 443:443
      - 8000-8002:8000-8002
      - 8004:8004
    depends_on:
      txn:
        condition: service_healthy
    healthcheck:
      test: exit 0

  search_master:
    image: search-app:latest
    hostname: search_master
    environment:
      - SOLR_MASTER=true
      - WORKAREA=/search
      - LICENSE=accept
      - TZ=Asia/Shanghai
    ports:
      - 3737:3737
      - 3738:3738
    extra_hosts:
    # IF you already have Db2 Docker container, you can remove this extra_host config for database
      - "db:<Auth DB server IP>"
    networks:
      default:
        aliases:
          - search
    depends_on:
      db:
        condition: service_healthy

#BASE64_ENCRYPTED_SPIUSER_PASSWORD  
#    1. run the following command: echo -n "spiuser:<plain text spiuser password>" | base64
#    2. use the output value to replace <BASE64_ENCRYPTED_SPIUSER_PASSWORD>     
    healthcheck:
      test: ["CMD", "curl", "-f", "-H", "Authorization: Basic <BASE64_ENCRYPTED_SPIUSER_PASSWORD>","http://localhost:3737/search/admin/resources/health/status?type=container"]
      interval: 20s
      timeout: 180s
      retries: 5

  store:
    image: crs-app:latest
    hostname: auth_store
    environment:
      - LICENSE=accept
      - TZ=Asia/Shanghai
    ports:
      - 8080:8080
      - 8443:8443
    depends_on:
      txn:
        condition: service_healthy
      search_master:
        condition: service_healthy
    healthcheck:
      test: curl -f http://localhost:8080/wcs/HealthCheck.jsp

  utils:
    image: ts-utils:latest
    hostname: auth_utils
    environment:
      - LICENSE=accept
      - DBHOST=db
      - DBNAME=<dbname>
      - DBPORT=<dbport>
      - DBUSER=<dbuser>
      - DBADMIN=<dbadmin>
      - ENABLE_DB_SSL=false
    tty: true
    healthcheck:
      test: exit 0
