Files
users/Dockerfile

36 lines
867 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.

# 神射手数据中台 - Docker 镜像NAS/生产)
# 多阶段:构建 Next.js standalone → 运行
FROM node:20-alpine AS builder
WORKDIR /app
# 依赖:仅复制 package.json在 Linux 下安装以得到正确的 @next/swc-linux-*(避免 darwin 专用包)
COPY package.json ./
RUN npm install
COPY . .
RUN (pnpm run build 2>/dev/null || npm run build)
# 运行阶段:仅保留 standalone 输出
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3117
EXPOSE 3117
# 从构建阶段复制 standalone
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
# 无 root 运行
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs && \
chown -R nextjs:nodejs /app
USER nextjs
CMD ["node", "server.js"]