# MCP Server Dockerfile
# Generated by Agent Builder Platform (template 1.0.0)

FROM python:3.13-slim-trixie

LABEL maintainer="Agent Builder Platform"
LABEL description="Read-only sample data for Agentic Landing Zone discovery (Meridian Retail Group) - scope, estate scans, CMDB and ITSM, inventory, schemas, dependencies, network and the run's MCP call log."
LABEL version="0.1.0"
LABEL server.id="alz-discovery-sample"
LABEL template.version="1.0.0"

WORKDIR /app

# Copy and install requirements
COPY requirements.txt .
COPY constraints.txt .
RUN pip install --no-cache-dir -r requirements.txt -c constraints.txt

# Copy application code
COPY server.py .
COPY mcp_connection.py .

# Create non-root user for security
RUN adduser --disabled-password --gecos '' appuser && \
    chown -R appuser:appuser /app
USER appuser

# Environment
# The ConfigMap's SERVER_PORT overrides this, so the container, Service and probes agree
ENV SERVER_PORT=8110
ENV PYTHONUNBUFFERED=1
ENV LOG_LEVEL=INFO
ENV LOG_FORMAT=json

# Expose port
EXPOSE 8110

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD python -c "import os, urllib.request; urllib.request.urlopen('http://localhost:%s/health' % (os.getenv('MCP_SERVER_PORT') or os.getenv('SERVER_PORT') or '8110'))" || exit 1

# Run the server
CMD ["python", "server.py"]
