hemant2747/multi-agent-framework
0
1# Single-container build: Next.js frontend (static export) served by the FastAPI2# backend on one port. Works for Hugging Face Spaces, Render, or any Docker host.3# Mode is decided by env vars (.env locally, or platform/Space secrets in cloud).4 5# ---- Stage 1: build the frontend to a static export (ui/out) ----6FROM node:20-slim AS frontend7WORKDIR /ui8COPY ui/package.json ui/package-lock.json* ./9RUN npm ci || npm install10COPY ui/ ./11# Same-origin: the frontend resolves the API base at runtime (see ui/lib/api.ts),12# so no NEXT_PUBLIC_API_BASE is baked here.13ENV STATIC_EXPORT=114RUN npm run build # -> /ui/out15 16# ---- Stage 2: python backend that also serves the static frontend ----17FROM python:3.12-slim18ENV PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1 PYTHONDONTWRITEBYTECODE=119# git is needed by the fetcher to clone repo URLs.20RUN apt-get update && apt-get install -y --no-install-recommends git \21 && rm -rf /var/lib/apt/lists/*22WORKDIR /app23 24COPY requirements.txt ./requirements.txt25COPY server/requirements.txt ./server-requirements.txt26RUN pip install -r requirements.txt -r server-requirements.txt27 28COPY . .29# Bring in the built frontend from stage 1.30COPY --from=frontend /ui/out ./ui/out31 32# Hugging Face Spaces expects the app on 7860; other hosts inject $PORT.33ENV PORT=786034EXPOSE 786035CMD ["sh", "-c", "uvicorn server.main:app --host 0.0.0.0 --port ${PORT:-7860}"]36 