c82f887a02
Add multi-platform Docker image build (amd64 + arm64) with GitHub Actions CI that pushes to GHCR on every merge to main. Users can self-host with a single `docker compose up -d` command. - Dockerfile: multi-stage build with Next.js standalone output (~150-200MB) - docker-compose.yml: one-command self-hosted deployment - .github/workflows/docker.yml: CI workflow with QEMU cross-compilation - next.config.ts: conditional `output: "standalone"` via BUILD_STANDALONE env - README (zh/en/ja): restructure deploy section to include Docker option Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
997 B
Docker
37 lines
997 B
Docker
FROM node:22-alpine AS base
|
|
RUN corepack enable && corepack prepare pnpm@9.12.0 --activate
|
|
|
|
# --- deps: install production + dev dependencies (cached layer) ---
|
|
FROM base AS deps
|
|
WORKDIR /app
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# --- builder: build Next.js standalone output ---
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV BUILD_STANDALONE=true
|
|
RUN pnpm build
|
|
|
|
# --- runner: minimal production image ---
|
|
FROM node:22-alpine AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV HOSTNAME=0.0.0.0
|
|
ENV PORT=3000
|
|
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /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
|
|
CMD ["node", "server.js"]
|