FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim # 🔧 System dependencies layer (cached unless OS changes) RUN apt-get update && apt-get install -y \ postgresql-client \ git \ curl \ build-essential \ gnupg \ ca-certificates \ && rm -rf /var/lib/apt/lists/* # 📦 Install Node.js LTS (cached until Node.js version changes) RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* \ && npm upgrade -g npm WORKDIR /app # 🧠 ML models cache setup (cached unless HF environment changes) RUN mkdir -p /app/.cache/huggingface && chmod 755 /app/.cache/huggingface ENV TRANSFORMERS_CACHE=/app/.cache/huggingface ENV HF_HOME=/app/.cache/huggingface # 🐍 Python dependencies layer (cached unless pyproject.toml/uv.lock changes) COPY pyproject.toml uv.lock ./ RUN uv sync --frozen --no-install-project # 📦 Node.js dependencies layer (cached unless package*.json changes) COPY package.json package-lock.json ./ RUN npm ci --only=production # 🚀 Application code and final setup (rebuilt on any code change) COPY . . RUN uv sync --frozen --no-editable # 🏗️ Frontend build (cached unless frontend code changes) RUN npm run build EXPOSE 8000 CMD ["python", "-m", "granian", "main:app", "--interface", "asgi", "--host", "0.0.0.0", "--port", "8000"]