version: "2.1"
services:
#####################################################################################################################
# The following section is for the database Docker image, assuming that you are using a database running inside a Docker container            
#image: The URL and tag to the database Docker image.                                                                       
#hostname: A name for the database container.                                                                        
#privileged: Gives extended priveleges to this container, which is needed to communicate with other containers.     
#LICENSE: Specify 'LICENSE=accept' to accept the terms and agreements and gain access to download             
#         the necessary Docker images.                                                                               
#TZ: The time zone. 
#ports: Database port 500000 is needed to communicate with the other containers. Do not change the database port.                                                                                                  
#####################################################################################################################
  db:
    image: commerce/ts-db:9.0.0.4
    hostname: live_db
    privileged: true
    environment:
      - LICENSE=accept
      - TZ=Toronto/Canada
    ports:
      - 50000:50000
    healthcheck:
      test: exit 0


#########################################################################################################
# The following section is for the transaction Docker image                                             
#image: The URL and tag to the transaction Docker image.                                                        
#hostname: A name for the transaction server container.                                                                                  
#LICENSE: Specify 'LICENSE=accept' to accept the terms and agreements and gain access to download 
#          the necessary Docker images.                                                                 
#TZ: The time zone.       
#ports: Ports exported by transaction server. Port 5443 is SSL port.  
#adminPassword: The password for user configadmin, which is used to access the WebSphere Application Server Administrative Console  
#   If you omit adminPassword, then the default password is config1admin                                                                                
#depends_on: The app container depends on the db container. The db container must be running                   
#            for the app container to start.         
#MERCHANTKEY_ENCRYPT: The encrypted merchant key that you created when you loaded the database schema.    
#   Merchant key is needed to decrypt the data read from the database.                                               
#########################################################################################################
  txn:
    image: commerce/ts-app:9.0.0.4
    hostname: live_txn
    environment:
      - LICENSE=accept
      - TZ=Toronto/Canada
      - adminPassword=passw0rd
      - DBHOST=db
      - DBNAME=mall
      - DBPORT=50000
      - DBUSER=wcs
      - DBPASS=wcs1
    volumes:
      - /opt/logs/TX:/opt/WebSphere/AppServer/profiles/default/logs/container
    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
      timeout: 180s
      retries: 100
      
##################################################################################################################################
# The following section is for the web Docker image                                                                              
#image: The URL and tag to the web server Docker image.                                                                                  
#hostname: A name for the web server container.                                                                                                                                                   
#LICENSE: Specify 'LICENSE=accept' to accept the terms and agreements and gain access to use the Docker images.   
#TZ: The time zone.  
#ports: Ports exported by web server. All ports are SSL ports.                                                                                                              
#depends_on: The web container depends on the txn container. The app container must be running for the web container to start.   
##################################################################################################################################
  web:
    image: commerce/ts-web:9.0.0.4
    hostname: live_web
    environment:
      - LICENSE=accept
      - TZ=Toronto/Canada
    volumes:
      - /opt/logs/TX-web/Plugin:/opt/WebSphere/Plugins/logs
      - /opt/logs/TX-web/HTTPServer:/opt/WebSphere/HTTPServer/logs
    ports:
      - 80:80
      - 443:443
      - 8000-8002:8000-8002
      - 8004:8004
    depends_on:
      txn:
        condition: service_healthy
    healthcheck:
      test: exit 0
   

#########################################################################################################
# The following section creates the search repeater                                            
#image: The URL and tag to the search Docker image.                                                             
#hostname: A name for the search repeater container.                                                      
#ports: Ports exported by search repeater server. Port 3738 is SSL port.                                         
#environment: Specify the type of search node for this search container.                                                                                       
#             - SOLR_MASTER=true                                                                      
#             - SOLR_SLAVE=true                                                                                                                                              
#LICENSE: Specify 'LICENSE=accept' to accept the terms and agreements and gain access to download 
#         the necessary Docker images.                                                                  
#TZ: The time zone.                                                                                     
#depends_on: The search container depends on the db container. The db container must be running         
#            for the search container to start. 
#SPIUSER_NAME: The spiuser name which you used to init database instance
#SPIUSER_PWD:  The spiuser password encrypted by using wcs_encrypt.sh. The value of plain text password be used to init database instance                                             
#DBHOST:       The database hostname. IF you use the database as container. the hostname is the service name of your container defined in docker-compose
#DBNAME:       The instance name of database
#DBPORT:       The port of database
#DBUSER:       The dbuser of database ( this is not the database admin user)
#DBPASS:       The plain text of password of database       
#healthcheck: Checks the health of Search server. 
#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>                                                 
#########################################################################################################
  search_repeater:
    image: commerce/search-app:9.0.0.4
    hostname: search_repeater
    environment:
      - SOLR_MASTER=true
      - SOLR_SLAVE=true
      - SOLR_MASTER_SERVER_URL=search:3738
      - WORKAREA=/search
      - LICENSE=accept
      - TZ=Toronto/Canada
    volumes:
      - /opt/logs/search_repeater:/opt/WebSphere/Liberty/usr/servers/default/logs/container
    ports:
      - 3737:3737
      - 3738:3738
    extra_hosts:
      - "search:10.31.9.208"
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "-H", "Authorization: Basic c3BpdXNlcjpwYXNzdzByZA==","http://localhost:3737/search/admin/resources/health/status?type=container"]
      interval: 10s
      timeout: 180s
      retries: 100

#########################################################################################################
# The following section creates the search slave                                            
#image: The URL and tag to the search Docker image.                                                             
#hostname: A name for the search slave container.                                                      
#ports: Ports exported by search server. Port 3738 is SSL port.                                         
#environment: Specify the type of search node for this search container.                                                                                       
#             - SOLR_MASTER=false                                                                      
#             - SOLR_SLAVE=true                                                                                                                                              
#LICENSE: Specify 'LICENSE=accept' to accept the terms and agreements and gain access to download 
#         the necessary Docker images.                                                                  
#TZ: The time zone.                                                                                     
#depends_on: The search container depends on the db container. The db container must be running         
#            for the search container to start.  
#SPIUSER_NAME: The spiuser name which you used to init database instance
#SPIUSER_PWD:  The spiuser password encrypted by using wcs_encrypt.sh. The value of plain text password be used to init database instance                                             
#DBHOST:       The database hostname. IF you use the database as container. the hostname is the service name of your container defined in docker-compose
#DBNAME:       The instance name of database
#DBPORT:       The port of database
#DBUSER:       The dbuser of database ( this is not the database admin user)
#DBPASS:       The plain text of password of database  
#SOLR_REPLICATION_POLLINTERVAL:  Interval in which the slave should poll master.   
#healthcheck: Checks the health of Search server. 
#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>                                                  
#########################################################################################################           
  search_slave:
    image: commerce/search-app:9.0.0.4
    hostname: search_slave
    entrypoint: bash -c "SEARCH=`ping -c 1 search_repeater | head -1 | awk -F \"(\" '{print $$2}' | awk -F \")\" '{print $$1}'` && 
                         echo $$SEARCH search >> /etc/hosts && 
                         /SETUP/bin/entrypoint.sh"
    environment:
      - SOLR_MASTER=false
      - SOLR_SLAVE=true
      - SOLR_MASTER_SERVER_URL=search:3738
      - SOLR_REPLICATION_POLLINTERVAL=00:00:60
      - WORKAREA=/search
      - LICENSE=accept
      - TZ=Toronto/Canada
    volumes:
      - /opt/logs/search_slave:/opt/WebSphere/Liberty/usr/servers/default/logs/container
    ports:
      - 3747:3737
      - 3748:3738
    depends_on:
      search_repeater:
        condition: service_healthy
    networks:
      default:
        aliases:
          - search
    healthcheck:
      test: ["CMD", "curl", "-f", "-H", "Authorization: Basic c3BpdXNlcjpwYXNzdzByZA==","http://localhost:3737/search/admin/resources/health/status?type=container"]
      interval: 10s
      timeout: 180s
      retries: 100


#########################################################################################################
# The following section is for the Store Docker image                                                   
#image: The URL and tag to the store Docker image.                                                              
#hostname: A name for the store server container.                                                       
#ports: Ports exported by store server. Port 8443 is SSL port.                                          
#LICENSE: Specify 'LICENSE=accept' to accept the terms and agreements and gain access to          
#         download the necessary Docker images.                                                         
#TZ: The time zone.                                                                                     
#depends_on: The store container depends on the txn container and search container.                     
#            The txn and search containers must be running for the store container to start.            
#########################################################################################################
  store:
    image: commerce/crs-app:9.0.0.4
    hostname: live_store
    environment:
      - LICENSE=accept
      - TZ=Toronto/Canada
    volumes:
      - /opt/logs/store:/opt/WebSphere/Liberty/usr/servers/default/logs/container
    ports:
      - 8080:8080
      - 8443:8443
    depends_on:
      txn:
        condition: service_healthy
      search_slave:
        condition: service_healthy        
    healthcheck:
      test: curl -f http://localhost:8080/wcs/HealthCheck.jsp
      interval: 10s
      timeout: 180s
      retries: 100


#################################################################################################################################
# The following section is for the Customization server Docker image                                                            
#image: The URL and tag to the utilities Docker image.                                                                                  
#hostname: A name for the customizationtainer.                                                                                                                                                                 
#LICENSE: Specify 'LICENSE=accept' to accept the terms and agreements and gain access to use the Docker images.   
#TZ: The time zone.                                                
#ports: Ports exported by customization container.  
#################################################################################################################################      
  xc:
    image: commerce/xc-app:9.0.0.4
    hostname: live_xc
    environment:
      - LICENSE=accept
      - TZ=Toronto/Canada
    volumes:
      - /opt/logs/xC:/opt/WebSphere/Liberty/usr/servers/default/logs/container
    ports:
      - 9080:9080
      - 9443:9443      

#################################################################################################################################
# The following section is for the utilities Docker image                                                                       
#image: The URL and tag to the utilities Docker image.                                                                                  
#hostname: A name for the utilities container.                                                                                  
#LICENSE: Specify 'LICENSE=accept' to accept the terms and agreements and gain access to use the Docker images.  
#DBHOST: The database host. 
#DBNAME: Database name.
#DBPORT: Port exported by the database server.
#DBUSER: The database user name.
#DBADMIN: The database administrator user name.                                                                            
#tty: Connects a pseudo terminal to access the utilities inside the container.                                                  
#################################################################################################################################
  utils:
    image: commerce/ts-utils:9.0.0.4
    hostname: live_utils
    environment:
      - LICENSE=accept
      - DBHOST=db
      - DBNAME=mall
      - DBPORT=50000
      - DBUSER=wcs
      - DBPASS=wcs1
      - DBADMIN=db2inst1
      - ENABLE_DB_SSL=false
    volumes:
        - /opt/logs/utils/product_level:/opt/WebSphere/CommerceServer90/logs
        - /opt/logs/utils/instance_level:/opt/WebSphere/CommerceServer90/instances/demo/logs
    tty: true
    healthcheck:
      test: exit 0

