inspection-host-computer/Dockerfile

35 lines
805 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 package.json package-lock.json pnpm-lock.yaml ./
RUN npm ci --omit=dev && npm cache clean --force
# 拷贝 Express 服务代码
COPY server/ ./server/
# 从构建阶段拷贝前端产物
COPY --from=builder /app/dist ./dist
# 暴露端口(与 Express 监听端口一致)
EXPOSE 3000
# 环境变量
ENV NODE_ENV=production
ENV VITE_SERVICE_PORT=3000
# 启动 Express 服务(使用 pnpm start 或 node server/index.js
CMD ["pnpm", "start"]