# ============================================
# 占位说明：请替换为公司内部 Python 基础镜像
# Python: registry.company.com/python:3.11
# ============================================
FROM registry.company.com/python:3.11 AS builder

WORKDIR /app
COPY pyproject.toml poetry.lock* ./
RUN pip install poetry && poetry install --no-dev

COPY . .

# 运行时镜像
FROM registry.company.com/python:3.11

# 非 root 用户（规范 §6.3）
RUN useradd -m -u 1000 appuser
USER appuser

WORKDIR /app
COPY --from=builder --chown=appuser:appuser /app /app

EXPOSE 8000

# 健康检查（规范 §6.4）
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD curl -f http://localhost:8000/health || exit 1

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
