version: '3.8'

services:
  postgres:
    image: postgres:15-alpine
    container_name: optiflow-db
    environment:
      POSTGRES_USER: optiflow
      POSTGRES_PASSWORD: optiflow123
      POSTGRES_DB: optiflow
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U optiflow"]
      interval: 5s
      timeout: 5s
      retries: 5

  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: optiflow-app
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgresql://optiflow:optiflow123@postgres:5432/optiflow
      NEXT_PUBLIC_API_URL: http://localhost:3000
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
      - ./src:/app/src
      - ./prisma:/app/prisma

volumes:
  postgres_data:
