# Use the official uv image for fast Python builds
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder

# Set the working directory
WORKDIR /app

# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# Copy the lockfile and pyproject.toml
COPY uv.lock pyproject.toml /app/

# Provide the version to hatch-vcs (setuptools-scm) during the build
ARG VERSION=dev
ENV SETUPTOOLS_SCM_PRETEND_VERSION=${VERSION}

# Install dependencies (without the project itself) for caching
RUN uv sync --frozen --no-install-project --no-dev

# Copy the source code and README (required by hatchling for metadata)
COPY src /app/src/
COPY README.md /app/

# Install the project
RUN uv sync --frozen --no-dev

# Make the executable available in the path
ENV PATH="/app/.venv/bin:$PATH"

# Default environment variables for the container
ENV MCP_TRANSPORT=http
ENV PORT=8000
ENV HOST=0.0.0.0

# Run the MCP server
ENTRYPOINT ["strava-mcp"]
