x-defaults: &defaults
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: 100m
      max-file: '3'

services:
  stirling-pdf:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}stirlingtools/stirling-pdf:${STIRLING_VERSION:-latest}
    ports:
      - '${STIRLING_PORT_OVERRIDE:-8080}:8080'
    volumes:
      - stirling_trainingData:/usr/share/tessdata
      - stirling_configs:/configs
      - stirling_logs:/logs
      - stirling_customFiles:/customFiles
    environment:
      - TZ=${TZ:-UTC}
      - DOCKER_ENABLE_SECURITY=${ENABLE_SECURITY:-false}
      - SECURITY_ENABLELOGIN=${ENABLE_LOGIN:-false}
      - SECURITY_INITIALLOGIN_USERNAME=${INITIAL_USERNAME:-admin}
      - SECURITY_INITIALLOGIN_PASSWORD=${INITIAL_PASSWORD:-admin}
      - INSTALL_BOOK_AND_ADVANCED_HTML_OPS=${INSTALL_ADVANCED_OPS:-false}
      - LANGS=${LANGUAGES:-en_GB}
      - PUID=${PUID:-1000}
      - PGID=${PGID:-1000}
      - UMASK=${UMASK:-022}
      - SYSTEM_DEFAULTLOCALE=${DEFAULT_LOCALE:-en-US}
      - UI_APPNAME=${APP_NAME:-Stirling-PDF}
      - UI_HOMEDESCRIPTION=${HOME_DESCRIPTION:-}
      - UI_APPNAMENAVBAR=${NAVBAR_NAME:-}
      - SYSTEM_MAXFILESIZE=${MAX_FILE_SIZE:-2000}
      - METRICS_ENABLED=${METRICS_ENABLED:-false}
      - SYSTEM_GOOGLEVISIBILITY=${GOOGLE_VISIBILITY:-false}
    deploy:
      resources:
        limits:
          cpus: ${STIRLING_CPU_LIMIT:-2.0}
          memory: ${STIRLING_MEMORY_LIMIT:-4G}
        reservations:
          cpus: ${STIRLING_CPU_RESERVATION:-1.0}
          memory: ${STIRLING_MEMORY_RESERVATION:-2G}
    healthcheck:
      test: [CMD, wget, --no-verbose, --tries=1, --spider, 'http://localhost:8080/']
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

volumes:
  stirling_trainingData:
  stirling_configs:
  stirling_logs:
  stirling_customFiles:
