-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (38 loc) · 1.96 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (38 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# ─────────────────────────────────────────────
# Stage 1: builder — install dependencies
# ─────────────────────────────────────────────
FROM python:3.12.10-slim AS builder
WORKDIR /app
# Install uv
COPY --from=ghcr.io/astral-sh/uv:0.11.6 /uv /usr/local/bin/uv
# Copy dependency files first for layer caching
COPY pyproject.toml uv.lock ./
COPY README.md ./
# Install only production dependencies (no dev extras)
RUN uv sync --frozen --no-dev
# ─────────────────────────────────────────────
# Stage 2: runtime — minimal production image
# ─────────────────────────────────────────────
FROM python:3.12.10-slim AS runtime
WORKDIR /app
# Create non-root user
RUN groupadd --gid 1001 deployer && \
useradd --uid 1001 --gid deployer --shell /bin/bash --no-create-home deployer
# Copy the virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Copy application source
COPY src/ ./src/
# Ensure the venv is on PATH
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
LABEL org.opencontainers.image.title="deployer" \
org.opencontainers.image.description="Production-ready deploy template for LLM applications" \
org.opencontainers.image.licenses="MIT"
USER deployer
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/ready')" || exit 1
# WORKERS controls uvicorn worker count. Default 1 for dev; set to (2*CPU+1) in production.
ENV WORKERS=1
CMD exec uvicorn deployer.main:app --host 0.0.0.0 --port 8000 --workers ${WORKERS}