# Multi-stage Dockerfile for RentCache FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS base # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ curl \ && rm -rf /var/lib/apt/lists/* # Copy dependency files COPY pyproject.toml uv.lock ./ # Install dependencies RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --frozen --no-install-project --no-dev # Copy source code COPY src/ ./src/ COPY README.md LICENSE ./ # Install the project RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --frozen --no-editable # Development stage FROM base AS development # Install development dependencies RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --frozen --no-editable # Create non-root user RUN groupadd -r rentcache && useradd -r -g rentcache rentcache RUN chown -R rentcache:rentcache /app USER rentcache # Create data directories RUN mkdir -p /app/data /app/logs EXPOSE 8000 # Development command with hot reload CMD ["uv", "run", "rentcache", "server", "--host", "0.0.0.0", "--port", "8000", "--reload"] # Production stage FROM base AS production # Create non-root user RUN groupadd -r rentcache && useradd -r -g rentcache rentcache RUN chown -R rentcache:rentcache /app USER rentcache # Create data directories RUN mkdir -p /app/data /app/logs # Compile bytecode for better performance ENV UV_COMPILE_BYTECODE=1 EXPOSE 8000 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD curl -f http://localhost:8000/health || exit 1 # Production command CMD ["uv", "run", "rentcache", "server", "--host", "0.0.0.0", "--port", "8000"]