feat: add multi-stage Dockerfile

This commit is contained in:
2025-12-29 20:06:38 -05:00
parent 374e4f669b
commit 013d1f88a2

45
Dockerfile Normal file
View File

@@ -0,0 +1,45 @@
# Stage 1: Builder
FROM python:3.14-slim AS builder
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install dependencies
RUN uv sync --frozen --no-dev --no-install-project
# Copy source code
COPY src ./src
# Install the project
RUN uv sync --frozen --no-dev
# Stage 2: Runtime
FROM python:3.14-slim
# Create non-root user
RUN useradd --create-home --shell /bin/bash appuser
WORKDIR /app
# Copy virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Copy source code
COPY --from=builder /app/src ./src
# Set environment
ENV PATH="/app/.venv/bin:$PATH"
ENV PORT=3000
# Switch to non-root user
USER appuser
EXPOSE 3000
CMD ["python", "-m", "grist_mcp.main"]