vanna-clubpetro/Dockerfile
Dalton Alvarenga 23828ee5ef
Some checks failed
CD / build (pull_request) Failing after 41s
fix(ci): volta build pra Cloud Build + bump Node 20 no webcomponent
- Reverte cd.yml pra Cloud Build (gcloud builds submit). Kaniko da PR #5
  quebra porque a imagem kaniko:debug não tem /bin/sleep no PATH e o
  act-runner usa entrypoint=["/bin/sleep","10800"] no container do job.
- Bump node:18 -> node:20 no stage do webcomponent (Vite >= 5 exige Node 20+).

Pré-requisito pro Cloud Build funcionar: SA gitea-cd precisa de
roles/cloudbuild.builds.editor + roles/serviceusage.serviceUsageConsumer.
2026-05-07 10:21:18 -03:00

61 lines
2.0 KiB
Docker

# syntax=docker/dockerfile:1.6
# Multi-stage:
# 1) Clona vanna-ai/vanna upstream (commit pinned em 365d061) e builda o webcomponent (~7.5MB)
# 2) Imagem Python 3.11 com vanna editable + requirements + código do app
ARG VANNA_UPSTREAM_COMMIT=365d0617c1a4567ffee1b19b40c27feb4206bfcf
# ============================================================================
# Stage 1 — webcomponent (Node)
# ============================================================================
FROM node:20-bookworm-slim AS webcomponent
ARG VANNA_UPSTREAM_COMMIT
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /vanna
RUN git init -q \
&& git remote add origin https://github.com/vanna-ai/vanna.git \
&& git fetch --depth 50 origin "$VANNA_UPSTREAM_COMMIT" \
&& git checkout FETCH_HEAD
WORKDIR /vanna/frontends/webcomponent
RUN npm install --no-audit --no-fund --loglevel=error \
&& npm run build \
&& ls -lh dist/vanna-components.js
# ============================================================================
# Stage 2 — runtime Python
# ============================================================================
FROM python:3.11-slim-bookworm
ARG VANNA_UPSTREAM_COMMIT
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
RUN apt-get update && apt-get install -y --no-install-recommends \
git ca-certificates curl build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copia o vanna upstream + bundle já buildado do stage 1
COPY --from=webcomponent /vanna /app/vanna
# Instala vanna editable
RUN pip install -e ./vanna
# Instala deps do app
COPY requirements.txt .
RUN pip install -r requirements.txt
# Código do app
COPY . .
# data dirs
RUN mkdir -p /app/chroma_db /app/data_storage
EXPOSE 8765
# `--workers 1` é OBRIGATÓRIO — múltiplos workers corrompem o SQLite do Chroma
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8765", "--workers", "1"]