mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-02 01:20:23 +08:00
* feat: Turn off certain features of quota popup for self-hosting This commit introduces a new variable, NEXT_PUBLIC_SELFHOSTED, that alters the behavior of the quota popup. Downstream consumers of the application may have their own quota-checking logic, and the front-end reacts to the 429 error by displaying the quota popup. In the case of a self-hosted version of the app, it is inappropriate to ask for sponsorship or provide a hyperlink to the public version of the tool to apply for an increased quota. An alternative string translation is provided with an empty message for adopter customization. To use this feature, compile with NEXT_PUBLIC_SELFHOSTED=true and those parts of the quota popup will be omitted. The downstream consumer is still expected to customize the internationalized strings for the popup content to be appropriate to their organization on their local forks. Signed-off-by: Bryon Nevis <bryon.nevis@intel.com> * refactor: improve readability and provide sensible selfhosted defaults - Extract nested ternary expressions into quotaMessage and tipHtml variables - Combine two separate !isSelfHosted conditional blocks into one - Replace null tipSelfHosted with meaningful default strings across all locales --------- Signed-off-by: Bryon Nevis <bryon.nevis@intel.com> Co-authored-by: dayuan.jiang <jdy.toh@gmail.com>
74 lines
2.0 KiB
Docker
74 lines
2.0 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 self-hosted draw.io URL
|
|
ARG NEXT_PUBLIC_DRAWIO_BASE_URL=https://embed.diagrams.net
|
|
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
|
|
|
|
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"]
|
|
|