services:
  postgres:
    image: postgres:16-alpine
    container_name: ten-minute-postgres-dev
    env_file:
      - ./.env.dev
    environment:
      TZ: Asia/Seoul
    volumes:
      - postgres_dev_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
      interval: 10s
      timeout: 5s
      retries: 10
    restart: unless-stopped

  backend:
    image: node:22-alpine
    container_name: ten-minute-backend-dev
    working_dir: /app
    command: sh -c "npm install && npm run dev"
    env_file:
      - ./.env.dev
    environment:
      PORT: 3001
      CORS_ORIGIN: http://localhost:5173
      SESSION_TTL_DAYS: 30
      TZ: Asia/Seoul
    volumes:
      - ./backend:/app
      - backend_node_modules:/app/node_modules
    depends_on:
      postgres:
        condition: service_healthy
    ports:
      - "3001:3001"
    restart: unless-stopped

  frontend:
    image: node:22-alpine
    container_name: ten-minute-frontend-dev
    working_dir: /app
    command: sh -c "npm install && npm run dev"
    environment:
      VITE_API_BASE_URL: http://localhost:3001
      CHOKIDAR_USEPOLLING: "true"
      TZ: Asia/Seoul
    volumes:
      - .:/app
      - /app/backend
      - frontend_node_modules:/app/node_modules
    depends_on:
      - backend
    ports:
      - "5173:5173"
    restart: unless-stopped

volumes:
  postgres_dev_data:
  backend_node_modules:
  frontend_node_modules:
