-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
105 lines (82 loc) · 3.67 KB
/
Copy pathDockerfile
File metadata and controls
105 lines (82 loc) · 3.67 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# ============================================================
# AgentLoom — Multi-stage Dockerfile
# ============================================================
# Stages:
# builder — install deps + build wheel
# dev — full dev environment (--target dev)
# production — runtime image WITH observability (default)
# production-lite — runtime image WITHOUT observability (~30 MB smaller)
#
# Usage:
# docker build -t agentloom . # production (observability)
# docker build --target production-lite -t al:lite .
# docker build --target dev -t agentloom:dev .
#
# The default image ships the [observability] extra so a container that
# sets OTEL_EXPORTER_OTLP_ENDPOINT exports traces out of the box. Choose
# `--target production-lite` for the smaller image when OTel is unused.
# ============================================================
# --------------- Stage 1: builder ---------------
FROM python:3.12-slim AS builder
# Install uv (fast Python package manager)
COPY --from=ghcr.io/astral-sh/uv:0.11.1 /uv /uvx /usr/local/bin/
WORKDIR /build
# Copy dependency files first (cache layer)
COPY pyproject.toml uv.lock ./
# Install dependencies (frozen = exact lockfile versions)
RUN uv sync --frozen --no-install-project --no-dev
# Copy source and build wheel
COPY src/ src/
COPY README.md ./
RUN uv build --wheel --out-dir /build/dist
# --------------- Stage 2: dev (--target dev) ---------------
FROM builder AS dev
# Install dev dependencies + all extras (observability)
RUN uv sync --frozen --group dev --all-extras
COPY src/ src/
COPY tests/ tests/
COPY examples/ examples/
WORKDIR /build
ENTRYPOINT ["uv", "run"]
CMD ["pytest"]
# --------------- Stage 3: runtime-base ---------------
# Everything the two runtime images share EXCEPT the dependency install.
# Keeping it in one stage means `production` and `production-lite` differ
# by exactly one line — the pip install — so they cannot drift apart.
FROM python:3.12-slim AS runtime-base
# Non-root user
RUN groupadd --gid 1000 agentloom \
&& useradd --uid 1000 --gid agentloom --create-home agentloom
# Stage the wheel for the install step in the child stages
COPY --from=builder /build/dist/*.whl /tmp/
# Copy example workflows so validate works out of the box. Recordings
# ride alongside so the mock-provider examples (embeddings, conversation,
# structured output) resolve their ``responses_file: recordings/…`` paths
# against the container's WORKDIR without a runtime mount.
COPY examples/ /workflows/
COPY recordings/ /workflows/recordings/
WORKDIR /workflows
# Default OTel endpoint for containerized environments
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
# OLLAMA_BASE_URL intentionally unset — set at runtime or via compose.
# Code defaults to http://localhost:11434 when unset.
ENTRYPOINT ["agentloom"]
CMD ["--help"]
# --------------- Stage 4: production-lite (--target production-lite) ---------------
# Runtime WITHOUT the observability extra — smaller image for deployments
# that do not export OTel traces / Prometheus metrics.
FROM runtime-base AS production-lite
RUN WHEEL=$(ls /tmp/agentloom-*.whl) \
&& pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check \
"$WHEEL" \
&& rm -f /tmp/*.whl
USER agentloom
# --------------- Stage 5: production (default) ---------------
# Runtime WITH the observability extra. Last stage in the file, so a
# bare `docker build .` produces this image.
FROM runtime-base AS production
RUN WHEEL=$(ls /tmp/agentloom-*.whl) \
&& pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check \
"${WHEEL}[observability]" \
&& rm -f /tmp/*.whl
USER agentloom