- Add AIAssistant component for intelligent user support - Implement EnhancedSearchModal with improved search functionality - Introduce LazyImage component for optimized image loading - Update HeroSection with responsive design classes - Modify Navigation to support dynamic base paths for production - Update Dockerfile with optimized multi-stage build and health checks - Configure docker-compose.yml with proper port mapping - Add comprehensive responsive CSS classes in index.css - Update routing configuration in App.tsx and main.tsx - Add development documentation in CLAUDE.md and QWEN.md - Configure build process with environment-specific base paths - Add optimization roadmap documentation Co-authored-by: Qwen-Coder <[email protected]>
68 lines
1.5 KiB
Docker
68 lines
1.5 KiB
Docker
# Node.js 应用 Dockerfile - 自动优化版本
|
|
# 由 docker-builder 生成
|
|
|
|
# 构建阶段
|
|
FROM node:18-alpine AS builder
|
|
|
|
# 清除代理配置,避免网络冲突
|
|
ENV HTTP_PROXY=""
|
|
ENV HTTPS_PROXY=""
|
|
ENV http_proxy=""
|
|
ENV https_proxy=""
|
|
# Force NODE_ENV and VITE_BASE to ensure correct build
|
|
ENV NODE_ENV=production
|
|
ENV VITE_BASE=/
|
|
|
|
WORKDIR /app
|
|
|
|
# 使用国内镜像源加速
|
|
RUN npm config delete proxy && \
|
|
npm config delete https-proxy && \
|
|
npm config set registry https://registry.npmmirror.com && \
|
|
npm config set cache /tmp/.npm --global
|
|
|
|
# 复制 package 文件
|
|
COPY package*.json ./
|
|
|
|
# 安装依赖
|
|
RUN npm install --frozen-lockfile
|
|
|
|
# 复制源代码
|
|
COPY . .
|
|
|
|
# 构建应用 with root base path for direct serving
|
|
RUN npm run build -- --base=/
|
|
|
|
# 生产阶段
|
|
FROM node:18-alpine AS production
|
|
|
|
# 清除代理配置
|
|
ENV HTTP_PROXY=""
|
|
ENV HTTPS_PROXY=""
|
|
ENV http_proxy=""
|
|
ENV https_proxy=""
|
|
|
|
WORKDIR /app
|
|
|
|
# 配置 npm 使用国内镜像源
|
|
RUN npm config delete proxy && \
|
|
npm config delete https-proxy && \
|
|
npm config set registry https://registry.npmmirror.com
|
|
|
|
# 只安装运行时工具
|
|
RUN npm install -g serve
|
|
|
|
# 复制构建产物
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/package.json ./
|
|
|
|
# 暴露端口
|
|
EXPOSE 3000
|
|
|
|
# 健康检查
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
|
|
|
|
# 启动应用
|
|
CMD ["serve", "-s", "dist", "-l", "3000"]
|