monitor-ai/Dockerfile

34 lines
923 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.

# monitor-ai Dockerfile
FROM node:22-alpine AS base
WORKDIR /app
# 1. 依赖安装
COPY package.json package-lock.json ./
RUN npm ci --production=false && npm ls bcryptjs 2>/dev/null || npm install bcryptjs
# 2. 复制共享库(构建前由部署脚本创建 symlink: shared -> ../shared
COPY shared/ ./shared/
# 3. 复制源码并构建
COPY . .
RUN npm run build
# 4. 生产镜像
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN apk add --no-cache sqlite docker-cli
COPY --from=base /app/.next/standalone ./
COPY --from=base /app/.next/static ./.next/static
COPY --from=base /app/scripts ./scripts
COPY --from=base /app/src/lib ./src/lib
COPY --from=base /app/shared ./shared
COPY tsconfig.json ./
COPY entrypoint.sh ./
RUN npm install -g tsx tsconfig-paths
# bcryptjs 未被 standalone 打包,需在 runner 阶段安装
RUN npm install bcryptjs
EXPOSE 6181
CMD ["sh", "entrypoint.sh"]