# Pulp 패치 관리 콘솔 — Coolify(Dockerfile build pack)용 이미지.
# 빌드 검증: 워크스페이스에서 `podman build -t pulp-console .` (MANUAL §10)
FROM python:3.13-slim

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PORT=8000

WORKDIR /app

# 1) 의존성 (레이어 캐시). 폐쇄망 반입 시 이 단계를 wheelhouse 오프라인 설치로 교체 — README 참고.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 2) 앱 소스 (정적자산·템플릿 포함 — 런타임 CDN 의존 0)
COPY app ./app

# 3) 비루트 실행
RUN useradd --create-home --uid 10001 appuser
USER appuser

EXPOSE 8000

# 라이브니스: /healthz 는 Pulp 와 무관하게 200 (Coolify health check 용)
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
  CMD python -c "import os,urllib.request; urllib.request.urlopen('http://127.0.0.1:%s/healthz' % os.environ.get('PORT','8000'))" || exit 1

CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8000}"]
