# Docker Compose for Local Development
# This file provides PostgreSQL and Redis for local development
# The Nuxt app runs natively on your Mac for faster hot reloads

version: '3.9'

services:
  # PostgreSQL Database
  db:
    image: postgres:16-alpine
    container_name: experimenta-db-dev
    restart: unless-stopped
    ports:
      - '5432:5432'
    environment:
      POSTGRES_DB: experimenta_dev
      POSTGRES_USER: dev
      POSTGRES_PASSWORD: dev_password_change_me
      POSTGRES_INITDB_ARGS: '--encoding=UTF8 --locale=C'
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U dev -d experimenta_dev']
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - experimenta-network

  # Redis (for BullMQ queues, sessions, caching)
  redis:
    image: redis:7-alpine
    container_name: experimenta-redis-dev
    restart: unless-stopped
    ports:
      - '6379:6379'
    command: >
      redis-server
      --appendonly yes
      --appendfsync everysec
      --save 60 1000
      --save 300 100
      --save 900 1
    volumes:
      - redis_data:/data
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 10s
      timeout: 3s
      retries: 5
    networks:
      - experimenta-network

  # Optional: Drizzle Studio (Database GUI)
  # Uncomment to enable database management UI at http://localhost:4983
  # drizzle-studio:
  #   image: node:20-alpine
  #   container_name: experimenta-drizzle-studio
  #   working_dir: /app
  #   command: sh -c "npm install -g drizzle-kit && drizzle-kit studio --host 0.0.0.0 --port 4983"
  #   ports:
  #     - '4983:4983'
  #   environment:
  #     DATABASE_URL: postgresql://dev:dev_password_change_me@db:5432/experimenta_dev
  #   depends_on:
  #     - db
  #   networks:
  #     - experimenta-network

volumes:
  postgres_data:
    name: experimenta-postgres-dev
    driver: local
  redis_data:
    name: experimenta-redis-dev
    driver: local

networks:
  experimenta-network:
    name: experimenta-dev-network
    driver: bridge
