# Build the wheel with uv, install it into a clean runtime image.
FROM python:3.12-slim AS builder

COPY --from=ghcr.io/astral-sh/uv:0.9.7 /uv /usr/local/bin/uv

# Version is stamped into pyproject.toml at build time (the git tag drives it
# in CI); the default keeps plain `docker build` working locally.
ARG VERSION=0.0.0

WORKDIR /src
COPY pyproject.toml uv.lock README.md ./
COPY persona ./persona
RUN sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml \
    && uv build --wheel --out-dir /dist


FROM python:3.12-slim

# `bash` runs whatever the agent asks for, so the image ships the basics an
# agent expects to find on a machine — git, curl, CA certificates.
RUN apt-get update \
    && apt-get install -y --no-install-recommends ca-certificates curl git \
    && rm -rf /var/lib/apt/lists/*

COPY --from=builder /dist /tmp/dist
RUN pip install --no-cache-dir /tmp/dist/*.whl && rm -rf /tmp/dist

# Default workspace the server chdirs into; mount a volume here to keep files.
ENV WORKSPACE_CWD=/workspace
RUN mkdir -p /workspace
WORKDIR /workspace

EXPOSE 9100

ENTRYPOINT ["persona-mcp-workspace"]
CMD ["--host", "0.0.0.0", "--port", "9100"]
