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

services:
  duckdb:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}davidgasquez/duckdb:${DUCKDB_VERSION:-v1.1.3}
    command: [duckdb, /data/duckdb.db]
    stdin_open: true
    tty: true
    environment:
      TZ: ${TZ:-UTC}
    volumes:
      - duckdb_data:/data
      # Mount additional data files
      # - ./data:/import:ro
    deploy:
      resources:
        limits:
          cpus: ${DUCKDB_CPU_LIMIT:-2.0}
          memory: ${DUCKDB_MEMORY_LIMIT:-4G}
        reservations:
          cpus: ${DUCKDB_CPU_RESERVATION:-0.1}
          memory: ${DUCKDB_MEMORY_RESERVATION:-512M}
    healthcheck:
      test: [CMD-SHELL, "duckdb /data/duckdb.db -c 'SELECT 1' || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

volumes:
  duckdb_data:
