forked from wso2/reference-implementations-afm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (53 loc) · 2.18 KB
/
Dockerfile
File metadata and controls
67 lines (53 loc) · 2.18 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
# Stage 1: Builder
FROM python:3.13-alpine AS builder
# Install uv for fast dependency management
COPY --from=ghcr.io/astral-sh/uv:0.10.0 /uv /uvx /bin/
# Set environment variables for uv and optimization
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
ENV UV_NO_DEV=1
# Change the working directory to the `app` directory
WORKDIR /app
# Install dependencies first (for better caching)
COPY uv.lock pyproject.toml README.md ./
COPY packages/afm-core/pyproject.toml packages/afm-core/README.md packages/afm-core/
COPY packages/afm-langchain/pyproject.toml packages/afm-langchain/README.md packages/afm-langchain/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-workspace --no-editable
# Copy workspace packages source
COPY packages/afm-core/src/ packages/afm-core/src/
COPY packages/afm-langchain/src/ packages/afm-langchain/src/
# Install only the packages we need (not afm-cli)
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-editable --package afm-core --package afm-langchain
# Stage 2: Final image
# VARIANT=full installs Node.js, npm (npx), git, and uv/uvx for MCP server support.
# VARIANT=slim ships only Python + .venv.
FROM python:3.13-alpine
ARG VARIANT=full
RUN if [ "$VARIANT" = "full" ]; then \
apk add --no-cache nodejs npm git && \
echo "Full variant: nodejs, npm, git installed"; \
fi
# Install uv and uvx for Python-based MCP server support (full variant only)
COPY --from=ghcr.io/astral-sh/uv:0.10.0 /uv /uvx /uv-bins/
RUN if [ "$VARIANT" = "full" ]; then \
mv /uv-bins/uv /uv-bins/uvx /bin/; \
fi && \
rm -rf /uv-bins
# Set working directory
WORKDIR /app
# Copy the virtual environment from the builder stage
COPY --from=builder /app/.venv /app/.venv
# Set environment variables
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
# Signal to the AFM update checker that it's running inside a container.
# This suppresses package-manager upgrade commands in update notifications
# since users should update by rebuilding or pulling the container image.
ENV AFM_RUNTIME=docker
# Expose default port for web interfaces
EXPOSE 8000
# Entry point to run the afm CLI
ENTRYPOINT ["afm"]
CMD ["--help"]