Files
forumlify/dockerfile
T
lezi-fun ec50efea89 feat: support serverless deployment (Vercel / Cloudflare Pages)
- Replace bcrypt (native) with bcryptjs (pure JS) — no native build on serverless
- Storage abstraction (lib/storage.js): local uploads/ for traditional deploy, S3-compatible (R2/MinIO/S3 via aws4fetch) for serverless
- DB pool auto-adapts to serverless (single connection, rotation, timeouts)
- next.config.js: standalone output only when DOCKER=1 (serverless skips it)
- Docs: serverless deployment section in README, S3 env vars in .env.example
2026-08-10 09:55:18 +08:00

33 lines
769 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================
# Forumlify (Next.js) 生产镜像 — standalone 模式
# ============================================================
# ---- 构建阶段 ----
FROM node:18-alpine AS builder
WORKDIR /app
ENV DOCKER=1
# 先装依赖(利用缓存)
COPY package.json package-lock.json* bun.lock* ./
RUN npm install
# 复制源码并构建
COPY . .
RUN npm run build
# ---- 运行阶段 ----
FROM node:18-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# standalone 输出(含 server.js 与最小 node_modules)
COPY --from=builder /app/.next/standalone ./
# 静态资源
COPY --from=builder /app/.next/static ./.next/static
# 上传目录
RUN mkdir -p /app/uploads
EXPOSE 3000
CMD ["node", "server.js"]