|
| 1 | +# ============================================================================= |
| 2 | +# repowise — multi-stage Docker build (backend + frontend) |
| 3 | +# ============================================================================= |
| 4 | +# Usage: |
| 5 | +# docker build -t repowise . |
| 6 | +# docker run -p 7337:7337 -p 3000:3000 -v /path/to/repo/.repowise:/data -e GEMINI_API_KEY=... repowise |
| 7 | +# ============================================================================= |
| 8 | + |
| 9 | +# --------------------------------------------------------------------------- |
| 10 | +# Stage 1: Build the Next.js frontend |
| 11 | +# --------------------------------------------------------------------------- |
| 12 | +FROM node:20-alpine AS frontend-builder |
| 13 | + |
| 14 | +WORKDIR /app |
| 15 | + |
| 16 | +# Install dependencies first (cached layer) |
| 17 | +COPY packages/web/package.json packages/web/package-lock.json* ./ |
| 18 | +RUN npm install --production=false |
| 19 | + |
| 20 | +# Copy source and build |
| 21 | +COPY packages/web/ ./ |
| 22 | +ENV NEXT_TELEMETRY_DISABLED=1 |
| 23 | +ENV NEXT_PUBLIC_REPOWISE_API_URL=http://localhost:7337 |
| 24 | +RUN npm run build |
| 25 | + |
| 26 | +# --------------------------------------------------------------------------- |
| 27 | +# Stage 2: Python backend + frontend runtime |
| 28 | +# --------------------------------------------------------------------------- |
| 29 | +FROM python:3.12-slim AS runtime |
| 30 | + |
| 31 | +# Install git (required by gitpython) and Node.js (required for Next.js server) |
| 32 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 33 | + git \ |
| 34 | + curl \ |
| 35 | + && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ |
| 36 | + && apt-get install -y --no-install-recommends nodejs \ |
| 37 | + && rm -rf /var/lib/apt/lists/* |
| 38 | + |
| 39 | +WORKDIR /app |
| 40 | + |
| 41 | +# Install repowise Python package |
| 42 | +COPY pyproject.toml README.md LICENSE MANIFEST.in ./ |
| 43 | +COPY packages/core/ packages/core/ |
| 44 | +COPY packages/cli/ packages/cli/ |
| 45 | +COPY packages/server/ packages/server/ |
| 46 | +RUN pip install --no-cache-dir ".[all]" |
| 47 | + |
| 48 | +# Copy built Next.js standalone output |
| 49 | +COPY --from=frontend-builder /app/.next/standalone /app/web |
| 50 | +COPY --from=frontend-builder /app/.next/static /app/web/.next/static |
| 51 | +COPY --from=frontend-builder /app/public /app/web/public 2>/dev/null || true |
| 52 | + |
| 53 | +# Data volume for .repowise directory |
| 54 | +VOLUME /data |
| 55 | + |
| 56 | +# Environment defaults |
| 57 | +ENV REPOWISE_DB_URL=sqlite+aiosqlite:///data/wiki.db |
| 58 | +ENV REPOWISE_EMBEDDER=mock |
| 59 | +ENV PORT_BACKEND=7337 |
| 60 | +ENV PORT_FRONTEND=3000 |
| 61 | +ENV HOSTNAME=0.0.0.0 |
| 62 | + |
| 63 | +# Expose both ports |
| 64 | +EXPOSE 7337 3000 |
| 65 | + |
| 66 | +# Startup script |
| 67 | +COPY docker/entrypoint.sh /app/entrypoint.sh |
| 68 | +RUN chmod +x /app/entrypoint.sh |
| 69 | + |
| 70 | +ENTRYPOINT ["/app/entrypoint.sh"] |
0 commit comments