services:
  postgres:
    image: postgres:15-alpine
    container_name: dashboard_postgres
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-dashboard}
      POSTGRES_USER: ${POSTGRES_USER:-dashboard}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-dashboard123}
      POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
    ports:
      - "${POSTGRES_PORT:-5432}:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./database/init:/docker-entrypoint-initdb.d
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-dashboard}"]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      - dashboard-network

  redis:
    image: redis:7-alpine
    container_name: dashboard_redis
    command: redis-server --appendonly yes --appendfsync everysec
    ports:
      - "${REDIS_PORT:-6379}:6379"
    volumes:
      - redis_data:/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      - dashboard-network

volumes:
  postgres_data:
    driver: local
  redis_data:
    driver: local

networks:
  dashboard-network:
    driver: bridge 