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

  backend:
    build:
      context: ./backend
    container_name: ten-minute-backend
    env_file:
      - ./.env
    environment:
      PORT: 3001
      CORS_ORIGIN: http://localhost:48081
      SESSION_TTL_DAYS: 30
      TZ: Asia/Seoul
    depends_on:
      postgres:
        condition: service_healthy
    expose:
      - "3001"
    restart: unless-stopped

  frontend:
    build:
      context: .
      args:
        VITE_API_BASE_URL: /api
    container_name: ten-minute-frontend
    environment:
      TZ: Asia/Seoul
    depends_on:
      - backend
    ports:
      - "48081:80"
    restart: unless-stopped

volumes:
  postgres_data:
