Files
chunyu_prject_react/Dockerfile
T
2026-08-05 23:59:22 +08:00

29 lines
473 B
Docker

FROM node:20-alpine AS builder
WORKDIR /app
# 复制依赖文件
COPY package*.json ./
# 安装依赖
RUN npm install --registry=https://registry.npmmirror.com
# 复制项目代码
COPY . .
# 构建项目
RUN npm run build
FROM nginx:alpine AS production
# 复制构建文件到Nginx
COPY --from=builder /app/dist /usr/share/nginx/html
# 复制Nginx配置
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 暴露端口
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]