services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: dash
      POSTGRES_USER: dash
      POSTGRES_PASSWORD: dash
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U dash -d dash"]
      interval: 5s
      timeout: 5s
      retries: 10

  app:
    build:
      context: .
      dockerfile: Dockerfile
    env_file:
      - .env.example
    environment:
      DATABASE_URL: postgres://dash:dash@postgres:5432/dash?sslmode=disable
      DATA_DIR: /data
      NEXT_PUBLIC_API_BASE_URL: http://localhost:8080
    ports:
      - "8080:8080"
      - "3000:3000"
    volumes:
      - backend-data:/data
    depends_on:
      postgres:
        condition: service_healthy

volumes:
  postgres-data:
  backend-data:
