2025-09-10 11:59:09 +03:00
|
|
|
# 🏗️ Multi-stage build for optimal caching and size
|
|
|
|
|
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim as builder
|
2025-02-10 19:10:13 +03:00
|
|
|
|
2025-09-10 11:00:46 +03:00
|
|
|
# 🔧 System dependencies layer (cached unless OS changes)
|
2025-02-10 19:10:13 +03:00
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
|
postgresql-client \
|
2025-08-12 13:12:39 +03:00
|
|
|
git \
|
2025-02-10 19:10:13 +03:00
|
|
|
curl \
|
2025-05-18 22:43:20 +00:00
|
|
|
build-essential \
|
2025-05-26 09:39:59 +03:00
|
|
|
gnupg \
|
|
|
|
|
ca-certificates \
|
2025-02-10 19:10:13 +03:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2025-09-10 11:00:46 +03:00
|
|
|
# 📦 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
|
|
|
|
|
|
2025-08-12 13:12:39 +03:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-09-10 11:59:09 +03:00
|
|
|
# 📦 Node.js dependencies layer (cached unless package*.json changes)
|
|
|
|
|
COPY package.json package-lock.json ./
|
|
|
|
|
RUN npm ci
|
|
|
|
|
|
|
|
|
|
# 🏗️ Frontend build (build with all dependencies)
|
|
|
|
|
COPY . .
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
# 🚀 Production stage
|
|
|
|
|
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
|
|
|
|
|
|
|
|
|
|
# 🔧 Runtime dependencies only
|
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
|
postgresql-client \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-09-10 11:00:46 +03:00
|
|
|
# 🧠 ML models cache setup (cached unless HF environment changes)
|
2025-09-01 15:09:36 +03:00
|
|
|
RUN mkdir -p /app/.cache/huggingface && chmod 755 /app/.cache/huggingface
|
|
|
|
|
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
|
|
|
|
|
ENV HF_HOME=/app/.cache/huggingface
|
|
|
|
|
|
2025-09-10 11:00:46 +03:00
|
|
|
# 🐍 Python dependencies layer (cached unless pyproject.toml/uv.lock changes)
|
|
|
|
|
COPY pyproject.toml uv.lock ./
|
|
|
|
|
RUN uv sync --frozen --no-install-project
|
2025-08-12 13:12:39 +03:00
|
|
|
|
2025-09-10 11:00:46 +03:00
|
|
|
# 🚀 Application code and final setup (rebuilt on any code change)
|
2025-02-10 19:10:13 +03:00
|
|
|
COPY . .
|
2025-09-10 11:00:46 +03:00
|
|
|
RUN uv sync --frozen --no-editable
|
|
|
|
|
|
2025-09-10 11:59:09 +03:00
|
|
|
# 📦 Copy built frontend from builder stage
|
|
|
|
|
COPY --from=builder /app/dist ./dist
|
2025-05-26 09:39:59 +03:00
|
|
|
|
2025-03-20 12:33:27 +03:00
|
|
|
EXPOSE 8000
|
2025-03-20 12:24:30 +03:00
|
|
|
|
2025-06-02 02:56:11 +03:00
|
|
|
CMD ["python", "-m", "granian", "main:app", "--interface", "asgi", "--host", "0.0.0.0", "--port", "8000"]
|