The Next.js app was proxying /api/* to the old Flask/FastAPI server at legal-ai.nautilus.marcusgroup.org. When that server went down, the Next.js app's API calls failed with 503. Now both services run in the same container: - FastAPI (uvicorn) on :8000 — the API backend - Next.js (node) on :3000 — proxies /api/* to localhost:8000 Changes: - Dockerfile: multi-stage build with Python 3.12 + Node.js - next.config.ts: default proxy target is now 127.0.0.1:8000 - start.sh: launches uvicorn in background + node in foreground - pyproject.toml: add fastapi + uvicorn as explicit deps Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
66 lines
2.5 KiB
Docker
66 lines
2.5 KiB
Docker
# ══════════════════════════════════════════════════════════════
|
|
# Dockerfile — Next.js frontend + FastAPI backend (single container)
|
|
#
|
|
# The container runs both:
|
|
# - FastAPI (uvicorn) on :8000 — the API backend
|
|
# - Next.js (node) on :3000 — the frontend (proxies /api/* to :8000)
|
|
#
|
|
# start.sh launches both processes.
|
|
# ══════════════════════════════════════════════════════════════
|
|
|
|
# ── Stage 1: Node deps ────────────────────────────────────────
|
|
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
COPY web-ui/package.json web-ui/package-lock.json ./
|
|
RUN npm ci --no-audit --no-fund
|
|
|
|
# ── Stage 2: Build Next.js ────────────────────────────────────
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY web-ui/ ./
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN npm run build
|
|
|
|
# ── Stage 3: Install Python deps ─────────────────────────────
|
|
FROM python:3.12-alpine AS pydeps
|
|
WORKDIR /opt/api
|
|
COPY mcp-server/ ./mcp-server/
|
|
RUN pip install --no-cache-dir ./mcp-server
|
|
|
|
# ── Stage 4: Runner ───────────────────────────────────────────
|
|
FROM python:3.12-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
# Install Node.js (needed for Next.js standalone server)
|
|
RUN apk add --no-cache nodejs
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
# Copy Python packages from pydeps stage
|
|
COPY --from=pydeps /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
|
COPY --from=pydeps /usr/local/bin/uvicorn /usr/local/bin/uvicorn
|
|
|
|
# Copy Next.js standalone build
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
# Copy FastAPI backend code
|
|
COPY web/ ./web/
|
|
COPY mcp-server/src/ ./mcp-server/src/
|
|
|
|
# Make mcp-server source available to web/app.py (it does sys.path.insert for legal_mcp)
|
|
ENV PYTHONPATH=/app/mcp-server/src
|
|
|
|
# Copy startup script
|
|
COPY start.sh ./start.sh
|
|
RUN chmod +x ./start.sh
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["./start.sh"]
|