|
| 1 | +# Taken reference from the following Dockerfile examples: |
| 2 | +# * UV Docker Example - https://github.com/astral-sh/uv-docker-example/blob/main/multistage.Dockerfile |
| 3 | +# * SQLite MCP Server Dockerfile - https://github.com/modelcontextprotocol/servers/blob/main/src/sqlite/Dockerfile |
| 4 | + |
| 5 | +FROM ghcr.io/astral-sh/uv:0.7-python3.10-bookworm-slim AS builder |
| 6 | + |
| 7 | +# Enable bytecode compilation |
| 8 | +ENV UV_COMPILE_BYTECODE=1 \ |
| 9 | + UV_LINK_MODE=copy \ |
| 10 | + DIRECTORY=mcp_wordle |
| 11 | + |
| 12 | +# Disable Python downloads, because we want to use the system interpreter |
| 13 | +# across both images. |
| 14 | +ENV UV_PYTHON_DOWNLOADS=0 |
| 15 | + |
| 16 | +WORKDIR /app |
| 17 | + |
| 18 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 19 | +--mount=type=bind,source=uv.lock,target=uv.lock \ |
| 20 | +--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ |
| 21 | +--mount=type=bind,source=.python-version,target=.python-version \ |
| 22 | +uv sync --frozen --no-install-project --no-dev --no-editable |
| 23 | + |
| 24 | +COPY uv.lock /app |
| 25 | +COPY pyproject.toml /app |
| 26 | +COPY README.md /app |
| 27 | +COPY .python-version /app |
| 28 | +ADD ./src/${DIRECTORY} /app/${DIRECTORY} |
| 29 | + |
| 30 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 31 | +uv sync --locked --no-dev |
| 32 | + |
| 33 | +# Then, use a final image without uv |
| 34 | +FROM python:3.10-slim-bookworm |
| 35 | + |
| 36 | +WORKDIR /app |
| 37 | + |
| 38 | +# Copy the application from the builder |
| 39 | +COPY --from=builder --chown=app:app /app /app |
| 40 | + |
| 41 | +# Place executables in the environment at the front of the path |
| 42 | +ENV PATH="/app/.venv/bin:$PATH" |
| 43 | +ENV PYTHONPATH=/app |
| 44 | + |
| 45 | +# Comes from 'pyproject.toml' |
| 46 | +ENTRYPOINT ["mcp-wordle"] |
0 commit comments