# Build with the python/ directory as the Docker context.
FROM ghcr.io/astral-sh/uv:0.13.5 AS uv
FROM python:3.11.17-slim
COPY --from=uv /uv /uvx /bin/
WORKDIR /app
ENV UV_PYTHON_DOWNLOADS=never
# Preserve the incoming system trust refresh before dependency downloads.
RUN apt-get update \
    && apt-get install -y --no-install-recommends ca-certificates \
    && update-ca-certificates \
    && rm -rf /var/lib/apt/lists/*
# The pinned uv installer verifies this wheel before any pip is executed.
RUN uv pip install --system --no-deps --require-hashes \
    "pip @ https://files.pythonhosted.org/packages/3f/06/3e4420302363fbb71be3c7f35ce042f54bfca330e3e66b3a2e3c4cca579f/pip-26.2.2-py3-none-any.whl#sha256=fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70"
COPY pyproject.toml uv.lock README.md ./
COPY src/ ./src/
# Install this checkout and its locked dependencies, never the older PyPI release.
RUN uv sync --frozen --no-dev --no-editable
# Check the global installer/OS stores and the separate application's certifi.
RUN python -c 'import hashlib, ssl; from pip._vendor import certifi; \
    stores = [ssl.create_default_context(cafile=p) for p in [certifi.where(), "/etc/ssl/certs/ca-certificates.crt"]]; \
    assert all(s.get_ca_certs() for s in stores); \
    assert all(hashlib.sha256(c).hexdigest() != "86a1ecba089c4a8d3bbe2734c612ba341d813e043cf9e8a862cd5c57a36bbe6b" for s in stores for c in s.get_ca_certs(binary_form=True))'
RUN /app/.venv/bin/python -c 'import certifi, hashlib, ssl; \
    store = ssl.create_default_context(cafile=certifi.where()); \
    assert store.get_ca_certs(); \
    assert all(hashlib.sha256(c).hexdigest() != "86a1ecba089c4a8d3bbe2734c612ba341d813e043cf9e8a862cd5c57a36bbe6b" for c in store.get_ca_certs(binary_form=True))'
USER 10001:10001
ENTRYPOINT ["/app/.venv/bin/mcp-server-bitbucket"]
