Files
KCGL/inventory-web/Dockerfile.prod

18 lines
519 B
Docker

# 第一阶段:构建 (Build Stage)
FROM node:20-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
# 执行构建,生成 dist 目录
RUN npm run build
# 第二阶段:生产服务 (Production Stage)
FROM nginx:stable-alpine as production-stage
# 复制构建好的 dist 文件到 Nginx 目录
COPY --from=build-stage /app/dist /usr/share/nginx/html
# 复制我们自定义的 nginx 配置
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]