Files
jiangmingzhao-daily-report/frontend/Dockerfile

37 lines
676 B
Docker
Raw Normal View History

# 构建阶段
FROM node:18-alpine as build-stage
# 设置工作目录
WORKDIR /app
# 复制package文件
COPY package*.json ./
# 安装依赖
RUN npm ci --only=production
# 复制源代码
COPY . .
# 构建应用
RUN npm run build
# 生产阶段
FROM nginx:alpine as production-stage
# 复制构建结果到nginx
COPY --from=build-stage /app/dist /usr/share/nginx/html
# 复制nginx配置
COPY nginx.conf /etc/nginx/nginx.conf
# 暴露端口
EXPOSE 80
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1
# 启动nginx
CMD ["nginx", "-g", "daemon off;"]