version: '3.8'

services:

  proxy:
    container_name: nginx-proxy
    restart: always
    depends_on:
      - solr
    build: nginx
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    environment:
      - SERVERNAME=${SERVERNAME}
      - PEMPATH=${PEMPATH}
    networks:
      - solr_network
    external_links:
      - solr
    volumes:
      - ./logs/:/etc/nginx/logs/
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf.template
      - ./nginx/start_nginx.sh:/sstm/nginx/start_nginx.sh
      - ./ssl/:/etc/ssl/nginx/
      - ./letsencrypt/:/etc/letsencrypt/
      - ./tmp/acme_challenge/:/var/www/html/
    command: /bin/bash /sstm/nginx/start_nginx.sh

    healthcheck:
      test: ["CMD", "curl", "-f", "http://${SERVERNAME}/health"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s

  solr:
    container_name: solr
    restart: always
    image: solr:8.11.2
    networks:
      - solr_network
    mem_limit: 4.1g
    expose:
      - 8983
    environment:
      - VIRTUAL_HOST=$SERVERNAME
      - HTTP_EXPOSE=8983
      - HTTPS_EXPOSE=8984:8983
      - SOLR_JAVA_MEM=-Xms3800m -Xmx3800m
    volumes:
      - ./start_solr.sh:/opt/solr/custom/start_solr.sh
      - ../configsets:/opt/solr/custom/configsets
      - ./solr:/var/solr/data
    logging:
      options:
        max-size: "10m"
        max-file: "3"
    entrypoint:
      - bash
      - "-c"
      - "/opt/solr/custom/start_solr.sh"

networks:
  solr_network:
    driver: bridge
