FROM python:3.12-slim

WORKDIR /app

# Install curl for healthcheck
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
RUN pip install --no-cache-dir fastmcp uvicorn pydantic python-frontmatter

# Copy documentation sources from repo root
COPY docs/tf_docs/docs /app/docs/tf_docs/docs
COPY docs/api_docs/public /app/docs/api_docs/public

# Copy server code
COPY tf_mcp_server /app/tf_mcp_server

# Set environment variables
ENV MCP_HOST=0.0.0.0
ENV MCP_PORT=8000
ENV DOCS_PATH=/app/docs/tf_docs/docs
ENV API_DOCS_PATH=/app/docs/api_docs/public
ENV BASE_PATH=/app
ENV PYTHONPATH=/app

# Expose port
EXPOSE 8000

# Health check for ECS
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
    CMD curl -f http://localhost:8000/health || exit 1

# Run the server
CMD ["python", "-m", "tf_mcp_server.server"]
