version: "2.1"
services:
  db:
    image: /commerce/ts-db:v9-latest
    hostname: auth_db
    privileged: true
    environment:
      - LICENSE=accept
      - TZ=Asia/Shanghai
    ports:
      - 50000:50000
    healthcheck:
      test: exit 0

  txn:
    image: /commerce/ts-app:v9-latest
    hostname: auth_txn
    environment:
      - LICENSE=accept
      - TZ=Asia/Shanghai
      - adminPassword=<admin_password>
      - DBHOST=db
      - DBNAME=mall
      - DBPORT=50000
      - DBUSER=wcs
      - DBADMIN=db2inst1
      - DBPASS=<db_password>
      - DBTYPE=db2
      - SPIUSER_PWD=<spi_user_password_aes>
    ports:
      - 5080:5080
      - 5443:5443
      - 9060:9060
      - 9043:9043
    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
    volumes:
      - /tmp/txn/logs:/profile/logs/server1

  web:
    image: /commerce/ts-web:v9-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

  shard_a:
    image: /commerce/search-app:test-shard
    hostname: search_shard_a
    environment:
      - WORKAREA=/shard_a
      - LICENSE=accept
      - TZ=Asia/Shanghai
      - ADMIN_SPIUSER_PWD=<admin_spiuser_password>
      - SPIUSER_PWD=<spi_user_password_aes>
      - DBHOST=db
      - DBNAME=mall
      - DBPORT=50000
      - DBUSER=wcs
      - DBADMIN=db2inst1
      - DBPASS=<db_password>
      - DBTYPE=db2
    ports:
      - 3747:3737
      - 3748:3738
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "-H", "Authorization: Basic <spiuser_password_base64>",
             "http://localhost:3737/search/admin/resources/health/ping"]
    volumes:
      - /shard_a

  shard_b:
    image: /commerce/search-app:test-shard
    hostname: search_shard_b
    environment:
      - WORKAREA=/shard_b
      - LICENSE=accept
      - TZ=Asia/Shanghai
      - ADMIN_SPIUSER_PWD=<admin_spiuser_password>
      - SPIUSER_PWD=<spi_user_password_aes>
      - DBHOST=db
      - DBNAME=mall
      - DBPORT=50000
      - DBUSER=wcs
      - DBADMIN=db2inst1
      - DBPASS=<db_password>
      - DBTYPE=db2
    ports:
      - 3757:3737
      - 3758:3738
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "-H", "Authorization: Basic <spiuser_password_base64>",
             "http://localhost:3737/search/admin/resources/health/ping"]
    volumes:
      - /shard_b

  shard_c:
    image: /commerce/search-app:test-shard
    hostname: search_shard_c
    environment:
      - WORKAREA=/shard_c
      - LICENSE=accept
      - TZ=Asia/Shanghai
      - ADMIN_SPIUSER_PWD=<admin_spiuser_password>
      - SPIUSER_PWD=<spi_user_password_aes>
      - DBHOST=db
      - DBNAME=mall
      - DBPORT=50000
      - DBUSER=wcs
      - DBADMIN=db2inst1
      - DBPASS=<db_password>
      - DBTYPE=db2
    ports:
      - 3767:3737
      - 3768:3738
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "-H", "Authorization: Basic <spiuser_password_base64>",
             "http://localhost:3737/search/admin/resources/health/ping"]
    volumes:
      - /shard_c


  master:
    image: /commerce/search-app:test-shard
    hostname: search_master
    environment:
      - SOLR_MASTER=true
      - WORKAREA=/search
      - LICENSE=accept
      - TZ=Asia/Shanghai
      - ADMIN_SPIUSER_PWD=<admin_spiuser_password>
      - SPIUSER_PWD=<spi_user_password_aes>
      - DBHOST=db
      - DBNAME=mall
      - DBPORT=50000
      - DBUSER=wcs
      - DBADMIN=db2inst1
      - DBPASS=<db_password>
      - DBTYPE=db2
    ports:
      - 3737:3737
      - 3738:3738
    networks:
      default:
        aliases:
          - search
    depends_on:
      db:
        condition: service_healthy
      shard_a:
        condition: service_started
      shard_b:
        condition: service_started
      shard_c:
        condition: service_started
    healthcheck:
      test: ["CMD", "curl", "-f", "-H", "Authorization: Basic <spiuser_password_base64>",
             "http://localhost:3737/search/admin/resources/health/ping"]
    volumes_from:
      - shard_a:rw
      - shard_b:rw
      - shard_c:rw

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

  utils:
    image: /commerce/ts-utils:v9-latest
    hostname: auth_utils
    environment:
      - LICENSE=accept
      - DBHOST=db
      - DBNAME=mall
      - DBPORT=50000
      - DBUSER=wcs
      - DBADMIN=db2inst1
      - DBPASS=<db_password>
      - SPIUSER_PWD=<spi_user_password_aes>
    healthcheck:
      test: exit 0
