services:
 ausaddressqp-setup:
    # Creates a self-signed cert for https communication between Elasticsearch and the app containers
    image: ausgnafapiservices/ausaddressqp:latest-setup
    volumes:
     - ausaddressqp_certs:/usr/share/certs
     - ausaddressqp_passwords:/usr/share/credentials
     - ausaddressqp_setup:/usr/share/essetup
    healthcheck:
     test: [ "CMD", "test", "-f", "/usr/share/certs/elastic-cert.key" ]
     interval: 3s
     timeout: 1s
     retries: 30

 ausaddressqp-essetup:
    image: ausgnafapiservices/ausaddressqp:latest-essetup
    environment:
     ES_HOST: ausaddressqpes01
     ES_SCHEME: https
     ES_PORT: 9200
     ES_CA_CERT: /usr/share/certs/elastic-cert.crt
    volumes:
     #- ./elasticsearch_permissions.yml:/setup/elasticsearch_permissions.yml
     - ausaddressqp_certs:/usr/share/certs
     - ausaddressqp_passwords:/usr/share/credentials
    networks:
     - ausaddressqpnet
    depends_on:
     - ausaddressqpes01

 ausaddressqpes01:
    image: elasticsearch:9.0.1
    container_name: ausaddressqpes01 # This is the default name used in the API
    environment:
     - discovery.type=single-node
     - cluster.name=ausaddressqpes
     - bootstrap.memory_lock=true
     - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
     memlock:
        soft: -1
        hard: -1
    restart: always
    volumes:
     - ausaddressqp_passwords:/usr/share/credentials
     - ausaddressqp_certs:/usr/share/certs
     - ausaddressqp_setup:/usr/share/essetup
     #- ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    entrypoint: [ "sh", "/usr/share/essetup/elasticsearch_startup.sh" ]
    networks:
     - ausaddressqpnet
    depends_on:
     ausaddressqp-setup:
        condition: service_completed_successfully

 ausaddressqpapi01:
    image: ausgnafapiservices/ausaddressqp:latest-NT # Smallest state with full Fed, State and LGA Data
    # options: latest-[NAT, ACT, NSW, NT, QLD, SA, TAS, VIC, WA]
    volumes:
     #- ./logs:/var/log/httpd
     - ausaddressqp_certs:/usr/share/certs
     - ausaddressqp_passwords:/usr/share/credentials
    ports:
     - 8000:80
    restart: always
    networks:
     - ausaddressqpnet
    environment:
     CORS_DOMAIN: "*" # Set this to localhost or your domain. Wildcard for Demo Purposes Only (NOT SAFE)
     ES_HOST: ausaddressqpes01
     ES_SCHEME: https
     ES_CA_CERT: /usr/share/certs/elastic-cert.crt
     ES_VERIFY_CERTS: "True" # if 7.x.x or lower, False
     ES_VERSION: 9.0.1 # if 7.x.x or lower, old no auth and http version used, if 8 or above new auth and https used
     ES_WAITFORPOST: "True" # This is for dev mode to check our post startup user roles and perms are setup yet
     #ES_INDEX: ausaddressqp # default index name, change if you have modified environment
     #ES_USER: elastic # default elasticsearch user, change if you have modified environment
     #ES_PASSWORD: changeme # default elasticsearch password, change if you have modified environment and not using setup container
     CREDENTIALS_FILE_PATH: /usr/share/credentials/es-setup-passwords.output
     PERMISSIONS_READY_FILE_PATH: /usr/share/credentials/es-setup-permissions.ready
    depends_on:
     - ausaddressqpes01

volumes:
 ausaddressqpes01_data:
    driver: local
 ausaddressqp_certs:
    driver: local
 ausaddressqp_passwords:
    driver: local
 ausaddressqp_setup:
    driver: local

networks:
    ausaddressqpnet:
