services:
  nginx:
    image: nginx:alpine
    container_name: image_server
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 64M
    ports:
      - "127.0.0.1:8002:80"  # 只在本地監聽，透過 NPM 訪問
    volumes:
      - ./nginx-config/default.conf:/etc/nginx/conf.d/default.conf:ro
      - .:/usr/share/nginx/html:ro  # 將 /home/bao/images 掛載為網頁根目錄
    networks:
      - npm_default
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

networks:
  npm_default:
    external: true
