40 lines
1.1 KiB
Docker
40 lines
1.1 KiB
Docker
# Dockerfile for MCP server
|
||
# Uses Python 3.12 slim image, installs the application and its dependencies
|
||
|
||
FROM python:3.12-slim AS base
|
||
|
||
# Install system dependencies (if any)
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
build-essential \
|
||
gcc \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# Create a non-root user
|
||
ARG USERNAME=appuser
|
||
ARG UID=1000
|
||
RUN adduser --uid ${UID} --disabled-password --gecos "" ${USERNAME}
|
||
|
||
# Set working directory
|
||
WORKDIR /app
|
||
|
||
# Copy only requirements first for caching layers
|
||
COPY pyproject.toml poetry.lock* /app/ || true
|
||
|
||
# Install poetry (or pip) and dependencies
|
||
RUN pip install --upgrade pip setuptools && \
|
||
pip install poetry && \
|
||
poetry config virtualenvs.create false && \
|
||
if [ -f poetry.lock ]; then poetry install --no-dev; else pip install .; fi
|
||
|
||
# Copy the rest of the source code
|
||
COPY . /app
|
||
|
||
# Switch to non-root user
|
||
USER ${USERNAME}
|
||
|
||
# Expose the service port (adjust if needed)
|
||
EXPOSE 8000
|
||
|
||
# Default command – run the FastAPI server (adjust entrypoint as needed)
|
||
CMD ["uvicorn", "mcp_server.main:app", "--host", "0.0.0.0", "--port", "8000"]
|