# ============================================================================
# DOCKER COMPOSE CONFIGS
# ============================================================================

x-network-policy: &network_policy
  sysctls:
    - net.ipv6.conf.all.disable_ipv6=1

x-restart-policy: &restart_policy
  restart: unless-stopped

x-healthcheck-defaults: &healthcheck_defaults
  interval: 30s
  timeout: 10s
  retries: 3
  start_period: 30s

# ============================================================================
# CORE DEPENDENCIES
# ============================================================================

services:
  postgres:
    <<: [*restart_policy, *network_policy]
    image: postgres:18
    container_name: sec_cybert_postgres
    command: postgres -c config_file=/etc/postgresql.conf
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: postgres
      POSTGRES_HOST_AUTH_METHOD: trust
      POSTGRES_INITDB_ARGS: "--auth-host=trust --auth-local=trust"
    ports:
      - "5432:5432"
    volumes:
      - sec_cybert_postgres_data:/var/lib/postgresql
      - ./resources/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
      - ./resources/postgresql.conf:/etc/postgresql.conf
    healthcheck:
      <<: *healthcheck_defaults
      test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]

volumes:
  sec_cybert_postgres_data:
