11# syntax=docker/dockerfile:1.7
22
3+ FROM ghcr.io/astral-sh/uv:python3.12-trixie-slim AS uv-tools
4+
35FROM python:3.12-slim AS builder
46
57ARG DEBIAN_FRONTEND=noninteractive
@@ -9,22 +11,26 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
911 PIP_ROOT_USER_ACTION=ignore \
1012 PIP_DISABLE_PIP_VERSION_CHECK=1
1113
12- WORKDIR /app
13-
1414# hadolint ignore=DL3008
1515RUN apt-get update \
1616 && apt-get install --no-install-recommends -y build-essential \
1717 && rm -rf /var/lib/apt/lists/*
1818
19- COPY pyproject.toml README.md ./
19+ COPY --from=uv-tools /usr/local/bin/uv /usr/bin/
20+
21+ WORKDIR /app
22+
23+ COPY pyproject.toml README.md uv.lock ./
2024COPY src ./src
2125
22- # hadolint ignore=DL3013
23- RUN pip install --no-cache-dir --upgrade pip \
24- && pip install --no-cache-dir build \
25- && python -m build --wheel --outdir /dist
26+ RUN uv build --wheel --out-dir /dist && \
27+ uv export \
28+ --format requirements-txt \
29+ --group ta \
30+ --no-emit-project \
31+ --output-file /dist/requirements.txt
2632
27- FROM python:3.12-slim AS runtime
33+ FROM python:3.12-slim
2834
2935ARG DEBIAN_FRONTEND=noninteractive
3036
@@ -38,11 +44,14 @@ RUN apt-get update \
3844 && apt-get install --no-install-recommends -y ca-certificates \
3945 && rm -rf /var/lib/apt/lists/*
4046
47+ COPY --from=uv-tools /usr/local/bin/uv /usr/bin/
48+
4149WORKDIR /workspace
4250
4351COPY --from=builder /dist/ /tmp/dist/
4452
45- RUN pip install --no-cache-dir /tmp/dist/*.whl \
53+ RUN uv pip install --system --no-cache -r /tmp/dist/requirements.txt \
54+ && uv pip install --system --no-cache /tmp/dist/*.whl \
4655 && rm -rf /tmp/dist
4756
4857LABEL org.opencontainers.image.title="Schwab MCP Server" \
0 commit comments