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

services:
  neo4j:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}neo4j:${NEO4J_VERSION:-5.27.4-community}
    ports:
      - '${NEO4J_HTTP_PORT_OVERRIDE:-7474}:7474'
      - '${NEO4J_BOLT_PORT_OVERRIDE:-7687}:7687'
    volumes:
      - neo4j_data:/data
      - neo4j_logs:/logs
      - neo4j_import:/var/lib/neo4j/import
      - neo4j_plugins:/plugins
    environment:
      - TZ=${TZ:-UTC}
      - NEO4J_AUTH=${NEO4J_AUTH:-neo4j/password}
      - NEO4J_ACCEPT_LICENSE_AGREEMENT=${NEO4J_ACCEPT_LICENSE_AGREEMENT:-yes}
      - NEO4J_dbms_memory_pagecache_size=${NEO4J_PAGECACHE_SIZE:-512M}
      - NEO4J_dbms_memory_heap_initial__size=${NEO4J_HEAP_INIT_SIZE:-512M}
      - NEO4J_dbms_memory_heap_max__size=${NEO4J_HEAP_MAX_SIZE:-1G}
    deploy:
      resources:
        limits:
          cpus: ${NEO4J_CPU_LIMIT:-2.0}
          memory: ${NEO4J_MEMORY_LIMIT:-2G}
        reservations:
          cpus: ${NEO4J_CPU_RESERVATION:-0.5}
          memory: ${NEO4J_MEMORY_RESERVATION:-1G}
    healthcheck:
      test: [CMD, wget, --no-verbose, --tries=1, --spider, 'http://localhost:7474/']
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

volumes:
  neo4j_data:
  neo4j_logs:
  neo4j_import:
  neo4j_plugins:
