Dockerfile.prod•1.95 kB
# Multi-stage Dockerfile for Hostaway MCP Server - Production
# Optimized for Hostinger VPS deployment with port 8080
# Stage 1: Builder - Install dependencies
# Stage 2: Runtime - Minimal production image
#
# Stage 1: Builder
#
FROM python:3.12-slim AS builder
# Set working directory
WORKDIR /app
# Install system dependencies for building Python packages
RUN apt-get update && apt-get install -y \
--no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install uv for fast dependency management
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH"
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Create minimal README if needed for build
RUN echo "# Hostaway MCP Server" > README.md
# Install dependencies using uv (creates .venv)
RUN uv sync --frozen --no-dev
#
# Stage 2: Runtime
#
FROM python:3.12-slim
# Set working directory
WORKDIR /app
# Install only runtime system dependencies
RUN apt-get update && apt-get install -y \
--no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Copy application code
COPY src/ ./src/
COPY pyproject.toml ./
# Create non-root user for security
RUN useradd -m -u 1000 mcpuser && \
chown -R mcpuser:mcpuser /app
# Switch to non-root user
USER mcpuser
# Set Python path to use virtual environment
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Health check (production port 8080)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:8080/health', timeout=5.0).raise_for_status()" || exit 1
# Expose production port
EXPOSE 8080
# Run FastAPI app with uvicorn on port 8080 (Hostinger standard)
CMD ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "8080"]