From 99f8ab11a8f14087adcd4695ec7458b3962a7cdc Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 09:37:59 +0000 Subject: [PATCH] Add frontend Dockerfile and integrate into docker-compose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Multi-stage Dockerfile (deps → build → runner) for optimized production image - Enable Next.js standalone output for minimal container size - Add .dockerignore to exclude dev artifacts from build context - Add frontend service to docker-compose.yml with API dependency https://claude.ai/code/session_01QU6gpDgMtX4b9k1UXTivEf --- docker-compose.yml | 15 +++++++++++++++ frontend/.dockerignore | 7 +++++++ frontend/Dockerfile | 42 +++++++++++++++++++++++++++++++++++++++++ frontend/next.config.ts | 2 +- 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 frontend/.dockerignore create mode 100644 frontend/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 3eef50d..b166f87 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,6 +49,21 @@ services: condition: service_healthy command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload + # --------------------------------------------------------------------------- + # CouncilOS Frontend — Next.js + React Flow UI + # --------------------------------------------------------------------------- + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + restart: unless-stopped + ports: + - "3000:3000" + environment: + NEXT_PUBLIC_API_URL: http://api:8000 + depends_on: + - api + volumes: postgres_data: chroma_data: diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..fd463df --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,7 @@ +node_modules +.next +.git +.gitignore +*.md +.env* +vitest.config.ts diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..614d9b9 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,42 @@ +FROM node:22-alpine AS base + +# --- Dependencies stage --- +FROM base AS deps +WORKDIR /app + +COPY package.json package-lock.json* ./ +RUN npm ci + +# --- Build stage --- +FROM base AS builder +WORKDIR /app + +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN npm run build + +# --- Production stage --- +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +CMD ["node", "server.js"] diff --git a/frontend/next.config.ts b/frontend/next.config.ts index e9ffa30..68a6c64 100644 --- a/frontend/next.config.ts +++ b/frontend/next.config.ts @@ -1,7 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - /* config options here */ + output: "standalone", }; export default nextConfig;