version: '3.8'

services:
  app:
    container_name: flyer-crawler-dev
    build:
      context: .
      dockerfile: Dockerfile.dev
    volumes:
      # Mount the current directory to /app in the container
      - .:/app
      # Create a volume for node_modules to avoid conflicts with Windows host
      # and improve performance.
      - node_modules_data:/app/node_modules
    ports:
      - '3000:3000' # Frontend (Vite default)
      - '3001:3001' # Backend API
    environment:
      - NODE_ENV=development
      - DB_HOST=postgres
      - DB_USER=postgres
      - DB_PASSWORD=postgres
      - DB_NAME=flyer_crawler_dev
      - REDIS_URL=redis://redis:6379
      # Add other secrets here or use a .env file
    depends_on:
      - postgres
      - redis
    # Keep container running so VS Code can attach
    command: tail -f /dev/null

  postgres:
    image: docker.io/library/postgis/postgis:15-3.4
    container_name: flyer-crawler-postgres
    ports:
      - '5432:5432'
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: flyer_crawler_dev
    volumes:
      - postgres_data:/var/lib/postgresql/data

  redis:
    image: docker.io/library/redis:alpine
    container_name: flyer-crawler-redis
    ports:
      - '6379:6379'

volumes:
  postgres_data:
  node_modules_data:
