FROM python:3.11-alpine

WORKDIR /app

# Install curl for uv installer and healthcheck.
# build-base + libffi are only needed if any wheel needs compiling; kept minimal.
RUN apk add --no-cache curl

# Install uv (fast Python package manager)
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:${PATH}"

# Install dependencies first (better layer caching)
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev

# Copy source
COPY src/ ./src/

# Non-root user for security
RUN adduser -D -u 1000 appuser && chown -R appuser:appuser /app
USER appuser

EXPOSE 8080

# Health check
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
    CMD curl -f http://localhost:8080/health || exit 1

# Run
CMD ["uv", "run", "uvicorn", "strength_training_mcp.server:app", \
     "--host", "0.0.0.0", "--port", "8080"]
