services:
  nats:
    image: nats:latest
    container_name: nats
    ports:
      - "4222:4222"  # NATS client port
      - "8222:8222"  # HTTP monitoring port
      - "6222:6222"  # Cluster port
    command:
      - "-js"                           # Enable JetStream
      - "-sd"                           # Store directory
      - "/data"
      - "-m"                            # Enable monitoring
      - "8222"
      - "--user"
      - "nats"
      - "--pass"
      - "nats123"
    volumes:
      - nats-data:/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
      interval: 10s
      timeout: 5s
      retries: 3

volumes:
  nats-data:
