# Flask API 服务 Dockerfile
# =========================
# 用于构建 Universal Data Fetcher API 服务的 Docker 镜像

FROM index-base:latest

# 设置工作目录
WORKDIR /app

# 复制依赖文件
COPY requirements.txt .

# 安装依赖
RUN uv pip install --system -r requirements.txt

# 仅复制除 data 目录外的应用代码
COPY . .

# 创建日志目录
RUN mkdir -p /app/logs

# 设置时区为上海
ENV TZ=Asia/Shanghai

# 暴露 Flask 服务端口
EXPOSE 5000

# 设置环境变量默认值
ENV FLASK_APP=core/datasource/flask_server.py
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1

# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD python -c "import requests; requests.get('http://localhost:5000/health')" || exit 1

# 启动 Flask 服务
CMD ["python", "core/datasource/flask_server.py", "--host", "0.0.0.0", "--port", "5000"]
