inspection-host-computer/Dockerfile
2026-06-29 16:19:37 +08:00

38 lines
766 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.

# ========== 阶段1构建前端 ==========
FROM node:20-alpine AS builder
RUN npm install -g pnpm
WORKDIR /app
# 先拷贝依赖文件,利用 Docker 缓存层
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# 拷贝源码并构建
COPY . .
RUN pnpm run build
# ========== 阶段2生产运行 ==========
FROM node:20-alpine AS runner
RUN npm install -g pnpm
WORKDIR /app
# 只拷贝生产需要的文件
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod && pnpm store prune
# 拷贝 Express 服务代码
COPY server/ ./server/
# 从构建阶段拷贝前端产物
COPY --from=builder /app/dist ./dist
EXPOSE 5175
ENV NODE_ENV=production
ENV VITE_SERVICE_PORT=5175
CMD ["node", "server/index.js"]