assets-ai/Dockerfile

23 lines
751 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.

# builder 阶段npm 依赖缓存跨构建持久化
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN apk add --no-cache python3 make g++
RUN --mount=type=cache,target=/root/.npm,id=assets-npm \
npm ci
COPY . .
RUN npm run build
# runner 阶段:与 builder 保持一致Alpine + musl确保 better-sqlite3 等原生模块兼容
FROM node:20-alpine AS runner
RUN apk add --no-cache python3 make g++
WORKDIR /app
COPY --from=builder /app/package.json /app/package-lock.json ./
RUN npm install --omit=dev
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
RUN mkdir -p /app/data /app/uploads
EXPOSE 3000
CMD ["node", "server.js"]