You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1.0 KiB
Docker

# backend/Dockerfile — phase-15 멀티스테이지(uv → slim)
FROM python:3.11-slim AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /app
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project
COPY . .
RUN uv sync --frozen --no-dev
# 운영 WSGI/ASGI 서버(테스트/로컬에는 불필요 — 이미지에서만 설치)
RUN uv pip install gunicorn "uvicorn[standard]"
FROM python:3.11-slim AS runtime
WORKDIR /app
ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1 ARI_ENV=prod
# 비루트 사용자
RUN useradd -m -u 10001 ari && mkdir -p /data /backups && chown -R ari:ari /data /backups
COPY --from=builder --chown=ari:ari /app /app
USER ari
EXPOSE 8000
# liveness 는 /api/health, readiness 는 /api/ready
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/api/health').status==200 else 1)"
CMD ["gunicorn", "app.main:app", "-c", "gunicorn.conf.py"]