FROM python:3.12-slim

# Links this container package to its Gitea repo (Gitea reads
# org.opencontainers.image.source to attach the package to the repo's
# Packages tab). Without it the image shows up unlinked under the user.
LABEL org.opencontainers.image.source="https://git.jpaul.io/justin/ag-bids-mcp" \
      org.opencontainers.image.title="ag-bids-mcp" \
      org.opencontainers.image.description="MCP server exposing ag-monitor commodity price data"

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1

RUN apt-get update && apt-get install -y --no-install-recommends \
      curl ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY ag_bids_mcp ./ag_bids_mcp

RUN mkdir -p /app/var/logs

# Streamable-HTTP transport in container; switch to stdio via env for dev.
ENV MCP_TRANSPORT=streamable-http \
    MCP_HOST=0.0.0.0 \
    MCP_PORT=8000 \
    USAGE_LOG_DIR=/app/var/logs \
    USAGE_LOG_KEEP_DAYS=90

EXPOSE 8000

CMD ["python", "-m", "ag_bids_mcp.server"]
