version: '3.8'

services:
  frontend:
    build:
      context: .
      dockerfile: Dockerfile.frontend
    ports:
      - "3000:3000"
    environment:
      - VITE_API_URL=/api
    depends_on:
      - backend
    volumes:
      - ./src:/app/src
      - ./public:/app/public

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    ports:
      - "3001:3001"
    environment:
      - NODE_ENV=production
      - PORT=3001
    volumes:
      - ./backend/database:/app/database
      - ./backend:/app
    command: ["sh", "-c", "node scripts/init-db.js && node server.js"]

volumes:
  db_data: