mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-07 02:07:47 +08:00
The canvas now fills the window and the chat floats on its right. draw.io is served from our own origin (public/drawio, downloaded at build time and checked against the release's SHA-256), so the app can drive the editor directly: - every AI change becomes a version card with a thumbnail; compare, restore or undo it, and Ctrl+Z on the canvas takes an AI change back in one step - shapes the AI just changed are highlighted on the canvas - selected shapes appear as a chip and are sent to the model - the app's own canvas toolbar, shape library and page tabs replace draw.io's chrome - new start screen, session rename and switcher, open .drawio files - settings split into Models & keys, Appearance, Advanced and About - phones switch between canvas and chat - dark mode keeps the diagram on a white sheet and no longer flashes With an external draw.io (NEXT_PUBLIC_DRAWIO_BASE_URL) the app falls back to draw.io's own toolbar and the features above that need same origin are off. The chat logic moved from the 1500-line chat panel into a chat engine plus small UI components; zustand holds canvas, versions, settings and UI state.
78 lines
2.2 KiB
Docker
78 lines
2.2 KiB
Docker
# Multi-stage Dockerfile for Next.js
|
|
|
|
# Stage 1: Install dependencies
|
|
FROM node:24-alpine AS deps
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json* ./
|
|
|
|
# Install dependencies
|
|
ARG ELECTRON_SKIP_BINARY_DOWNLOAD=1
|
|
RUN npm install
|
|
|
|
# Stage 2: Build application
|
|
FROM node:24-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Copy node_modules from deps stage
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Disable Next.js telemetry during build
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Build-time argument for an external draw.io URL. Leave empty to use the
|
|
# copy bundled into public/drawio (downloaded by `npm run build`)
|
|
ARG NEXT_PUBLIC_DRAWIO_BASE_URL=""
|
|
ENV NEXT_PUBLIC_DRAWIO_BASE_URL=${NEXT_PUBLIC_DRAWIO_BASE_URL}
|
|
|
|
# Build-time argument to show About link and Notice icon
|
|
ARG NEXT_PUBLIC_SHOW_ABOUT_AND_NOTICE=false
|
|
ENV NEXT_PUBLIC_SHOW_ABOUT_AND_NOTICE=${NEXT_PUBLIC_SHOW_ABOUT_AND_NOTICE}
|
|
|
|
# Build-time argument for subdirectory deployment (e.g., /nextaidrawio)
|
|
ARG NEXT_PUBLIC_BASE_PATH=""
|
|
ENV NEXT_PUBLIC_BASE_PATH=${NEXT_PUBLIC_BASE_PATH}
|
|
|
|
# Control sponsorship and self-hosting messaging in quota notifications.
|
|
# Set NEXT_PUBLIC_SELFHOSTED="true" in self-hosted deployments to hide sponsorship/self-host links and related text in quota popups.
|
|
ARG NEXT_PUBLIC_SELFHOSTED=""
|
|
ENV NEXT_PUBLIC_SELFHOSTED="${NEXT_PUBLIC_SELFHOSTED}"
|
|
|
|
# Build Next.js application (standalone mode)
|
|
RUN npm run build
|
|
|
|
# Stage 3: Production runtime
|
|
FROM node:24-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Create non-root user for security
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Copy necessary files
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Copy standalone build output
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
# Writable dir for admin panel settings (data/settings.json)
|
|
RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
# Start the application (HOSTNAME override needed for AWS App Runner)
|
|
CMD ["sh", "-c", "HOSTNAME=0.0.0.0 exec node server.js"]
|
|
|