# GeoSight MCP Server Dockerfile
# Multi-stage build for optimized production image
# ==============================================================================
# Stage 1: Build stage
# ==============================================================================
FROM python:3.11-slim as builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libgdal-dev \
libgeos-dev \
libproj-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY pyproject.toml ./
RUN pip install --no-cache-dir build && \
pip wheel --no-cache-dir --wheel-dir /wheels -e .
# ==============================================================================
# Stage 2: Production stage
# ==============================================================================
FROM python:3.11-slim as production
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libgdal32 \
libgeos3.11.1 \
libproj25 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd --create-home --shell /bin/bash geosight
# Copy wheels from builder
COPY --from=builder /wheels /wheels
# Install Python packages
RUN pip install --no-cache-dir /wheels/* && \
rm -rf /wheels
# Copy application code
COPY src/ ./src/
COPY config/ ./config/
# Create directories
RUN mkdir -p /app/data /app/logs /app/models/weights && \
chown -R geosight:geosight /app
# Switch to non-root user
USER geosight
# Environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
ENVIRONMENT=production \
LOG_LEVEL=INFO \
SERVER_MODE=stdio \
MODEL_WEIGHTS_DIR=/app/models/weights
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Expose port for HTTP mode
EXPOSE 8000
# Default command
CMD ["python", "-m", "geosight.server"]
# ==============================================================================
# Stage 3: Development stage
# ==============================================================================
FROM production as development
USER root
# Install development dependencies
RUN pip install --no-cache-dir \
pytest \
pytest-asyncio \
pytest-cov \
black \
ruff \
mypy \
ipython
# Install additional tools
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
vim \
&& rm -rf /var/lib/apt/lists/*
USER geosight
ENV ENVIRONMENT=development \
LOG_LEVEL=DEBUG
CMD ["python", "-m", "geosight.server"]