version: "3.8"

services:
  app:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    ports:
      - "5001:5000"
    environment:
      - DATABASE_URL=postgresql://todouser:todopass@postgres:5432/todos
      - UPLOAD_FOLDER=/tmp/todo_uploads
      - PORT=5001
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5001/health"]
      interval: 10s
      timeout: 5s
      retries: 5

  postgres:
    image: postgres:15-alpine
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_USER=todouser
      - POSTGRES_PASSWORD=todopass
      - POSTGRES_DB=todos
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U todouser -d todos"]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  postgres_data:
