version: '3.8'

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile.low-mem
    container_name: diet_recommendation_app_low_mem
    ports:
      - "5000:5000"
    environment:
      - FLASK_ENV=production
      - PYTHONUNBUFFERED=1
      - PYTHONHASHSEED=0
      - MALLOC_ARENA_MAX=2
    volumes:
      # 持久化数据目录
      - ./data:/app/data
      - ./logs:/app/logs
      - ./models:/app/models
    restart: unless-stopped
    # 内存限制（小内存机器配置）
    deploy:
      resources:
        limits:
          memory: 512M
        reservations:
          memory: 256M
    networks:
      - app-network
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:5000/health').read()"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 15s

networks:
  app-network:
    driver: bridge

