version: '3.7'
services:
  # Frontend service
  web-app:
    image: openmf/web-app:master
    restart: always
    environment:
      - FINERACT_API_URLS=http://localhost:8080
      - FINERACT_API_URL=http://localhost:8080
      - FINERACT_API_PROVIDER=/fineract-provider/api
      - FINERACT_API_VERSION=/v1
      - FINERACT_PLATFORM_TENANT_IDENTIFIER=default
      - MIFOS_DEFAULT_LANGUAGE=en-US
      - MIFOS_SUPPORTED_LANGUAGES=cs-CS,de-DE,en-US,es-MX,fr-FR,it-IT,ko-KO,li-LI,lv-LV,ne-NE,pt-PT,sw-SW
      - MIFOS_PRELOAD_CLIENTS=true
      - MIFOS_DEFAULT_CHAR_DELIMITER=,
    ports:
      - 80:80
  # Database service
  fineractmysql:
    image: mariadb:10.8
    ports:
      - 3308:3306
    volumes:
#Remove comment for data persistence
#      - ./fineract-db/data:/var/lib/mysql
      - ./fineract-db/server_collation.cnf:/etc/mysql/conf.d/server_collation.cnf
      - ./fineract-db/max_connections.cnf:/etc/mysql/conf.d/max_connections.cnf
      - ./fineract-db/docker:/docker-entrypoint-initdb.d:Z,ro
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: skdcnwauicn2ucnaecasdsajdnizucawencascdca
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "--password=skdcnwauicn2ucnaecasdsajdnizucawencascdca" ]
      timeout: 10s
      retries: 10
  # Backend service
  fineract-server:
    image: openmf/fineract:develop
    volumes:
      - ./fineract-server/data:/data
    healthcheck:
      test: ["CMD", 'sh', '-c', 'echo -e "Checking for the availability of Fineract server deployment"; while ! nc -z "fineract-server" 8443; do sleep 1; printf "-"; done; echo -e " >> Fineract server ha>
      timeout: 10s
      retries: 10
    ports:
      - 8080:8080
    depends_on:
      fineractmysql:
        condition: service_healthy
    environment:
      # NOTE: node aware scheduler
      - FINERACT_NODE_ID=1
      # NOTE: env vars prefixed "FINERACT_HIKARI_*" are used to configure the database connection pool
      - FINERACT_HIKARI_DRIVER_SOURCE_CLASS_NAME=org.mariadb.jdbc.Driver
      - FINERACT_HIKARI_JDBC_URL=jdbc:mariadb://fineractmysql:3306/fineract_tenants
      - FINERACT_HIKARI_USERNAME=root
      - FINERACT_HIKARI_PASSWORD=skdcnwauicn2ucnaecasdsajdnizucawencascdca
      # ... following variables are optional; "application.properties" contains reasonable defaults (same as here)
- FINERACT_HIKARI_MINIMUM_IDLE=3
      - FINERACT_HIKARI_MAXIMUM_POOL_SIZE=10
      - FINERACT_HIKARI_IDLE_TIMEOUT=60000
      - FINERACT_HIKARI_CONNECTION_TIMEOUT=20000
      - FINERACT_HIKARI_TEST_QUERY=SELECT 1
      - FINERACT_HIKARI_AUTO_COMMIT=true
      - FINERACT_HIKARI_DS_PROPERTIES_CACHE_PREP_STMTS=true
      - FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SIZE=250
      - FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SQL_LIMIT=2048
      - FINERACT_HIKARI_DS_PROPERTIES_USE_SERVER_PREP_STMTS=true
      - FINERACT_HIKARI_DS_PROPERTIES_USE_LOCAL_SESSION_STATE=true
      - FINERACT_HIKARI_DS_PROPERTIES_REWRITE_BATCHED_STATEMENTS=true
      - FINERACT_HIKARI_DS_PROPERTIES_CACHE_RESULT_SET_METADATA=true
      - FINERACT_HIKARI_DS_PROPERTIES_CACHE_SERVER_CONFIGURATION=true
      - FINERACT_HIKARI_DS_PROPERTIES_ELIDE_SET_AUTO_COMMITS=true
      - FINERACT_HIKARI_DS_PROPERTIES_MAINTAIN_TIME_STATS=false
      - FINERACT_HIKARI_DS_PROPERTIES_LOG_SLOW_QUERIES=true
      - FINERACT_HIKARI_DS_PROPERTIES_DUMP_QUERIES_IN_EXCEPTION=true
      # NOTE: env vars prefixed "FINERACT_DEFAULT_TENANTDB_*" are used to create the default tenant database
      - FINERACT_DEFAULT_TENANTDB_HOSTNAME=fineractmysql
      - FINERACT_DEFAULT_TENANTDB_PORT=3306
      - FINERACT_DEFAULT_TENANTDB_UID=root
      - FINERACT_DEFAULT_TENANTDB_PWD=skdcnwauicn2ucnaecasdsajdnizucawencascdca
      - FINERACT_DEFAULT_TENANTDB_CONN_PARAMS=
      - FINERACT_DEFAULT_TENANTDB_TIMEZONE=Asia/Kolkata
      - FINERACT_DEFAULT_TENANTDB_IDENTIFIER=default
      - FINERACT_DEFAULT_TENANTDB_NAME=fineract_default
      - FINERACT_DEFAULT_TENANTDB_DESCRIPTION=Default Demo Tenant
      - FINERACT_SERVER_SSL_ENABLED=false
      - FINERACT_SERVER_PORT=8080
      - FINERACT_LOGGING_LEVEL=INFO