assets-ai/Dockerfile

25 lines
906 B
Docker
Raw Permalink 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 阶段:使用 Debianglibc与 txjp 宿主机平台一致,避免原生模块 musl/glibc 不兼容
FROM node:20-slim AS runner
WORKDIR /app
COPY --from=builder /app/package.json /app/package-lock.json ./
COPY --from=builder /app/.next/standalone ./
RUN npm install --omit=dev && \
npm rebuild better-sqlite3 && \
rm -rf node_modules/@img/sharp-linuxmusl-x64 node_modules/@img/sharp-libvips-linuxmusl-x64 \
node_modules/@next/swc-linux-x64-musl
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"]