inspection-host-computer/Dockerfile
2026-06-26 10:51:01 +08:00

27 lines
724 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.

# 使用 Node 基础镜像
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install --frozen-lockfile
# 复制源码并构建
COPY . .
RUN pnpm run build
# 生产阶段:只复制必要文件
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/server ./server
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install --prod --frozen-lockfile
# 暴露端口(与 Express 监听端口一致)
EXPOSE 3000
# 启动 Express 服务(使用 pnpm start 或 node server/index.js
CMD ["pnpm", "start"]
# 或直接 CMD ["node", "server/index.js"]