diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..22a1510 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,45 @@ +# 依赖目录 +node_modules +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# 构建输出 +dist +build + +# 环境文件 +.env +.env.local +.env.development +.env.production + +# 测试相关 +coverage +.nyc_output + +# 编辑器文件 +.vscode +.idea +*.swp +*.swo + +# 系统文件 +.DS_Store +Thumbs.db + +# Git +.git +.gitignore + +# Docker相关 +.dockerignore +Dockerfile +docker-compose.yml + +# 日志文件 +logs +*.log + +# 临时文件 +tmpclaude-* \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa0926a --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +dist/ +.env +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e5ec3f4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# 构建阶段 +FROM node:20-alpine AS builder + +# 设置工作目录 +WORKDIR /app + +# 复制package.json和package-lock.json +COPY package*.json ./ + +# 安装依赖 +RUN npm ci --only=production --ignore-scripts && \ + npm ci --only=development --ignore-scripts + +# 复制源代码 +COPY . . + +# 构建参数:API基础URL(默认为相对路径 /api,通过Nginx代理) +ARG VITE_API_BASE_URL=/api +ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} + +# 构建应用 +RUN npm run build + +# 运行时阶段 - 使用Nginx提供静态文件 +FROM nginx:alpine AS runtime + +# 复制Nginx配置 +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# 从构建阶段复制构建产物 +COPY --from=builder /app/dist /usr/share/nginx/html + +# 暴露端口 +EXPOSE 80 + +# 启动Nginx +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..37ae696 --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + +
+ + +